mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-31 11:46:37 +00:00
fix: empty background restore after reboot (#1379)
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pocket-id/pocket-id/backend/internal/storage"
|
"github.com/pocket-id/pocket-id/backend/internal/storage"
|
||||||
"github.com/pocket-id/pocket-id/backend/internal/utils"
|
"github.com/pocket-id/pocket-id/backend/internal/utils"
|
||||||
@@ -76,6 +77,18 @@ func initApplicationImages(ctx context.Context, fileStorage storage.FileStorage)
|
|||||||
dstNameToExt[nameWithoutExt] = ext
|
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
|
// Copy images from the images directory to the application-images directory if they don't already exist
|
||||||
for _, sourceFile := range sourceFiles {
|
for _, sourceFile := range sourceFiles {
|
||||||
if sourceFile.IsDir() {
|
if sourceFile.IsDir() {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function compareExports(dir1: string, dir2: string): void {
|
|||||||
const hashes2 = hashAllFiles(dir2);
|
const hashes2 = hashAllFiles(dir2);
|
||||||
|
|
||||||
const files1 = Object.keys(hashes1).sort();
|
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);
|
expect(files2).toEqual(files1);
|
||||||
|
|
||||||
for (const file of files1) {
|
for (const file of files1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user