diff --git a/backend/internal/bootstrap/app_images_bootstrap.go b/backend/internal/bootstrap/app_images_bootstrap.go index fb8d6fe5..0d026d08 100644 --- a/backend/internal/bootstrap/app_images_bootstrap.go +++ b/backend/internal/bootstrap/app_images_bootstrap.go @@ -12,6 +12,7 @@ import ( "log/slog" "os" "path" + "strings" "github.com/pocket-id/pocket-id/backend/internal/storage" "github.com/pocket-id/pocket-id/backend/internal/utils" @@ -76,6 +77,18 @@ func initApplicationImages(ctx context.Context, fileStorage storage.FileStorage) dstNameToExt[nameWithoutExt] = ext } + initedPath := path.Join("application-images", ".inited") + if _, _, err := fileStorage.Open(ctx, initedPath); err == nil { + return dstNameToExt, nil + } else if !os.IsNotExist(err) { + return nil, fmt.Errorf("failed to read .inited: %w", err) + } else { + err := fileStorage.Save(ctx, initedPath, strings.NewReader("")) + if err != nil { + return nil, fmt.Errorf("failed to store .inited: %w", err) + } + } + // Copy images from the images directory to the application-images directory if they don't already exist for _, sourceFile := range sourceFiles { if sourceFile.IsDir() { diff --git a/tests/specs/cli.spec.ts b/tests/specs/cli.spec.ts index e6116575..8b1733f8 100644 --- a/tests/specs/cli.spec.ts +++ b/tests/specs/cli.spec.ts @@ -109,7 +109,7 @@ function compareExports(dir1: string, dir2: string): void { const hashes2 = hashAllFiles(dir2); const files1 = Object.keys(hashes1).sort(); - const files2 = Object.keys(hashes2).sort(); + const files2 = Object.keys(hashes2).sort().filter(p => !p.includes('.inited')); expect(files2).toEqual(files1); for (const file of files1) {