Prevent deletion when re-selecting already stored custom sound

This commit is contained in:
Beingpax 2025-11-18 14:32:21 +05:45
parent ff0be0092b
commit 8525392f03

View File

@ -133,6 +133,10 @@ class CustomSoundManager: ObservableObject {
let newFilename = "\(standardName).\(fileExtension)" let newFilename = "\(standardName).\(fileExtension)"
let destinationURL = directory.appendingPathComponent(newFilename) let destinationURL = directory.appendingPathComponent(newFilename)
if sourceURL.resolvingSymlinksInPath() == destinationURL.resolvingSymlinksInPath() {
return .success(newFilename)
}
if FileManager.default.fileExists(atPath: destinationURL.path) { if FileManager.default.fileExists(atPath: destinationURL.path) {
try? FileManager.default.removeItem(at: destinationURL) try? FileManager.default.removeItem(at: destinationURL)
} }