mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-26 00:06:02 +00:00
Refactoring
This commit is contained in:
1 parent
bb86ebc606
commit
ce77e73428
2 files changed
+2
-14
No files matched your search
@@ -471,24 +471,12 @@ public class SaveFilesManager {
|
||||
for file in files {
|
||||
|
||||
let fileName = file.lastPathComponent
|
||||
var destinationURL = target.appendingPathComponent(fileName)
|
||||
let destinationURL = target.appendingPathComponent(fileName)
|
||||
|
||||
if !filesFinishedDownloading.contains(destinationURL) {
|
||||
log("File \(file) not finished downloading, skipping")
|
||||
log("Pending files: \(filesFinishedDownloading)")
|
||||
continue
|
||||
}
|
||||
|
||||
var counter = 1
|
||||
let fileExtension = destinationURL.pathExtension
|
||||
let baseName = destinationURL.deletingPathExtension().lastPathComponent
|
||||
|
||||
while fileManager.fileExists(atPath: destinationURL.path) {
|
||||
let newFileName = "\(baseName)-\(counter)"
|
||||
let newFileNameWithExtension = fileExtension.isEmpty ? newFileName : "\(newFileName).\(fileExtension)"
|
||||
destinationURL = target.appendingPathComponent(newFileNameWithExtension)
|
||||
counter += 1
|
||||
}
|
||||
|
||||
log("Moving file: \(file.lastPathComponent) to \(destinationURL.lastPathComponent)")
|
||||
try fileManager.copyItem(at: file, to: destinationURL)
|
||||
|
||||
Reference in new issue
Block a user