Skip to content
Closed
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
2 changes: 1 addition & 1 deletion internal/database/health_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ func (r *HealthRepository) batchInsertAutomaticHealthChecks(ctx context.Context,
)
VALUES %s
ON CONFLICT(file_path) DO UPDATE SET
library_path = excluded.library_path,
library_path = COALESCE(excluded.library_path, library_path),
release_date = excluded.release_date,
scheduled_check_at = excluded.scheduled_check_at,
status = excluded.status,
Expand Down
17 changes: 16 additions & 1 deletion internal/health/library_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/javi11/altmount/internal/config"
"github.com/javi11/altmount/internal/database"
"github.com/javi11/altmount/internal/metadata"
metapb "github.com/javi11/altmount/internal/metadata/proto"
"github.com/javi11/altmount/pkg/rclonecli"
"github.com/sourcegraph/conc/pool"
)
Expand Down Expand Up @@ -287,7 +288,13 @@ func (lsw *LibrarySyncWorker) findFilesToDelete(
continue
}

if _, exists := filesInUse[dbRecord.FilePath]; !exists {
cfg := lsw.configGetter()
fullMountPath := filepath.Join(cfg.MountPath, dbRecord.FilePath)

_, existsAsFullPath := filesInUse[fullMountPath]
_, existsAsRelativePath := filesInUse[dbRecord.FilePath]

if !existsAsFullPath && !existsAsRelativePath {
filesToDelete = append(filesToDelete, dbRecord.FilePath)
}
}
Expand Down Expand Up @@ -570,6 +577,10 @@ func (lsw *LibrarySyncWorker) SyncLibrary(ctx context.Context, dryRun bool) *Dry
if regErr != nil {
slog.ErrorContext(ctx, "Failed to register corrupted file", "path", path, "error", regErr)
}
// Update metadata file status
if statusErr := lsw.metadataService.UpdateFileStatus(path, metapb.FileStatus_FILE_STATUS_CORRUPTED); statusErr != nil {
slog.ErrorContext(ctx, "Failed to update metadata file status to corrupted", "path", path, "error", statusErr)
}
}
continue
}
Expand Down Expand Up @@ -1205,6 +1216,10 @@ func (lsw *LibrarySyncWorker) syncMetadataOnly(ctx context.Context, startTime ti
if regErr != nil {
slog.ErrorContext(ctx, "Failed to register corrupted file", "path", path, "error", regErr)
}
// Update metadata file status
if statusErr := lsw.metadataService.UpdateFileStatus(path, metapb.FileStatus_FILE_STATUS_CORRUPTED); statusErr != nil {
slog.ErrorContext(ctx, "Failed to update metadata file status to corrupted", "path", path, "error", statusErr)
}
continue
}
if fileMeta == nil {
Expand Down
Loading