mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-12 19:41:11 +00:00
Improve logging
This commit is contained in:
1 parent
4c95be694f
commit
e47934a0a8
1 file changed
+14
-14
@@ -30,10 +30,10 @@ public class SaveFilesManager {
|
||||
}
|
||||
|
||||
if didSomething {
|
||||
log("Temporary directory cleared.")
|
||||
log("[SaveFilesManager] Temporary directory cleared.")
|
||||
}
|
||||
} catch {
|
||||
log("Failed to list contents of temp directory: \(error)")
|
||||
log("[SaveFilesManager] Failed to list contents of temp directory: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SaveFilesManager {
|
||||
for file in files {
|
||||
|
||||
if !loggedExecution {
|
||||
log("Moving pending files to target directory")
|
||||
log("[SaveFilesManager] Moving pending files to target directory")
|
||||
loggedExecution = true
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ public class SaveFilesManager {
|
||||
let destinationURL = target.appendingPathComponent(fileName)
|
||||
|
||||
if !filesFinishedDownloading.contains(destinationURL) {
|
||||
log("File \(file) not finished downloading, skipping")
|
||||
log("[SaveFilesManager] File \(file) not finished downloading, skipping")
|
||||
continue
|
||||
}
|
||||
|
||||
log("Moving file: \(file.lastPathComponent) to \(destinationURL.lastPathComponent)")
|
||||
log("[SaveFilesManager] Moving file: \(file.lastPathComponent) to \(destinationURL.lastPathComponent)")
|
||||
|
||||
do {
|
||||
try fileManager.copyItem(at: file, to: destinationURL)
|
||||
@@ -104,10 +104,10 @@ public class SaveFilesManager {
|
||||
try fileManager.removeItem(at: file)
|
||||
}
|
||||
catch {
|
||||
log("Error moving file: \(error)")
|
||||
log("[SaveFilesManager] Error moving file: \(error)")
|
||||
}
|
||||
}
|
||||
log("Moved all pending files to target directory")
|
||||
log("[SaveFilesManager] Moved all pending files to target directory")
|
||||
}
|
||||
catch {
|
||||
// Pending directory doesn't exist or is empty
|
||||
@@ -118,7 +118,7 @@ public class SaveFilesManager {
|
||||
|
||||
#if os(macOS)
|
||||
if UserDefaults.standard.bool(forKey: UserDefaultsKeys.openFinderAfterReceiving.rawValue) {
|
||||
log("Opening \(filesFinishedDownloadingSinceLastRun.count) file(s) in Finder.")
|
||||
log("[SaveFilesManager] Opening \(filesFinishedDownloadingSinceLastRun.count) file(s) in Finder.")
|
||||
NSWorkspace.shared.activateFileViewerSelecting(filesFinishedDownloadingSinceLastRun)
|
||||
}
|
||||
#endif
|
||||
@@ -136,7 +136,7 @@ public class SaveFilesManager {
|
||||
return
|
||||
}
|
||||
|
||||
log("Stopping access to security scoped resource: \(url)")
|
||||
log("[SaveFilesManager] Stopping access to security scoped resource: \(url)")
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
securityScopeUrl = nil
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class SaveFilesManager {
|
||||
|
||||
public func getSaveDirectory() -> URL {
|
||||
if let securityScopeUrl = securityScopeUrl {
|
||||
log("Using existing security scope URL: \(securityScopeUrl)")
|
||||
log("[SaveFilesManager] Using existing security scope URL: \(securityScopeUrl)")
|
||||
return securityScopeUrl
|
||||
}
|
||||
|
||||
@@ -158,17 +158,17 @@ public class SaveFilesManager {
|
||||
|
||||
if !isStale {
|
||||
if url.startAccessingSecurityScopedResource() {
|
||||
log("Successfully accessed security scoped resource: \(url)")
|
||||
log("[SaveFilesManager] Successfully accessed security scoped resource: \(url)")
|
||||
|
||||
securityScopeUrl = url
|
||||
return url
|
||||
}
|
||||
} else {
|
||||
log("Bookmark is stale, using default downloads folder.")
|
||||
log("[SaveFilesManager] Bookmark is stale, using default downloads folder.")
|
||||
}
|
||||
|
||||
} catch {
|
||||
log("Failed to resolve bookmark: \(error), using default downloads folder.")
|
||||
log("[SaveFilesManager] Failed to resolve bookmark: \(error), using default downloads folder.")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class SaveFilesManager {
|
||||
do {
|
||||
return try FileManager.default.url(for: .downloadsDirectory, in: .userDomainMask, appropriateFor: nil, create: true).resolvingSymlinksInPath()
|
||||
} catch {
|
||||
fatalError("Failed to get downloads directory: \(error)")
|
||||
fatalError("[SaveFilesManager] Failed to get downloads directory: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user