fix: empty background restore after reboot (#1379)

This commit is contained in:
taoso
2026-03-27 01:33:30 +08:00
committed by GitHub
parent fc52bd4efb
commit 724c41cb7a
2 changed files with 14 additions and 1 deletions

View File

@@ -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() {

View File

@@ -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) {