Fix file metadata save

This commit is contained in:
Christoph Hagen
2026-01-08 22:40:25 +01:00
parent 07ba77e337
commit 57fa5aa3dd
3 changed files with 13 additions and 0 deletions

View File

@@ -235,3 +235,10 @@ enum FileType: String {
} }
} }
} }
extension FileType: CustomStringConvertible {
var description: String {
rawValue
}
}

View File

@@ -108,6 +108,9 @@ struct AddFileView: View {
content.add(resource) content.add(resource)
selectedFile = resource selectedFile = resource
} }
// We need to ensure that the metadata file is written to disk directly
content.saveUnconditionally()
content.generateMissingVideoThumbnails() content.generateMissingVideoThumbnails()
dismiss() dismiss()
} }

View File

@@ -181,6 +181,7 @@ struct FileDetailView: View {
markFileAsChanged() markFileAsChanged()
if file.isExternallyStored { if file.isExternallyStored {
DispatchQueue.main.async { DispatchQueue.main.async {
// This will also trigger a save
file.isExternallyStored = false file.isExternallyStored = false
} }
} }
@@ -215,6 +216,7 @@ struct FileDetailView: View {
return return
} }
DispatchQueue.main.async { DispatchQueue.main.async {
// This will also trigger a save
file.fileSize = nil file.fileSize = nil
file.isExternallyStored = true file.isExternallyStored = true
} }
@@ -225,6 +227,7 @@ struct FileDetailView: View {
print("File '\(file.identifier)': Failed to delete file in content folder") print("File '\(file.identifier)': Failed to delete file in content folder")
return return
} }
// This will also trigger a save
content.remove(file) content.remove(file)
selection.remove(file) selection.remove(file)
} }