Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions backend/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,16 +860,12 @@ func (d *Database) deleteAssetsNotIn(ctx context.Context, userID string, assetID
if err := bulkInsertTemp(ctx, tx, "tmpKeepAssets", assetIDs); err != nil {
return fmt.Errorf("populate temp table: %w", err)
}
defer func() {
if _, err := tx.ExecContext(ctx, "DROP TABLE IF EXISTS tmpKeepAssets"); err != nil {
log.Printf("[DB] Failed to drop temp table: %v", err)
}
}()

if _, err := tx.ExecContext(ctx, "DELETE FROM assets WHERE userID = ? AND immichID NOT IN (SELECT val FROM tmpKeepAssets)", userID); err != nil {
return fmt.Errorf("delete stale assets: %w", err)
}

tx.ExecContext(ctx, "DROP TABLE IF EXISTS tmpKeepAssets")
return tx.Commit()
}

Expand Down
8 changes: 7 additions & 1 deletion backend/syncService.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ func (s *SyncService) doUserFullSync(ctx context.Context, userID string, immich

s.syncStacks(ctx, userID, immich)
if err := s.syncLibraries(ctx, userID, immich); err != nil {
log.Printf("[Sync] Library sync failed during full sync for user %s: %v", userID, err)
// A 401/403 only means the key is not an admin key: syncLibraries already logs
// that as an expected condition, so don't repeat it here as a failure.
var httpErr *ImmichHTTPError
isMissingAccess := errors.As(err, &httpErr) && (httpErr.StatusCode == http.StatusUnauthorized || httpErr.StatusCode == http.StatusForbidden)
if !isMissingAccess {
log.Printf("[Sync] Library sync failed during full sync for user %s: %v", userID, err)
}
s.db.deleteSyncState(ctx, userID, "libraryIDBackfillDone")
} else {
if err := s.db.setSyncState(ctx, userID, "libraryIDBackfillDone", "true"); err != nil {
Expand Down
Loading