diff --git a/TagTunes/Artwork.swift b/TagTunes/Artwork.swift
index de18c9e..3997c4d 100644
--- a/TagTunes/Artwork.swift
+++ b/TagTunes/Artwork.swift
@@ -54,6 +54,10 @@ public class Artwork: iTunesType {
public func saveToURL(url: NSURL, filename: String) throws {
let directory = url.filePathURL!.path!
let filePath = directory.stringByAppendingString("/\(filename).tiff")
+
+ if !Preferences.sharedPreferences.overwriteExistingFiles && NSFileManager.defaultManager().fileExistsAtPath(filePath) {
+ return
+ }
try NSFileManager.defaultManager().createDirectoryAtPath(directory, withIntermediateDirectories: true, attributes: nil)
let _ = NSFileManager.defaultManager().createFileAtPath(filePath, contents: saveImage?.TIFFRepresentation, attributes: nil)
diff --git a/TagTunes/Base.lproj/Main.storyboard b/TagTunes/Base.lproj/Main.storyboard
index 0a0f4b0..418d33a 100644
--- a/TagTunes/Base.lproj/Main.storyboard
+++ b/TagTunes/Base.lproj/Main.storyboard
@@ -760,11 +760,11 @@ CA
-
+
+
+
+
+
+
+
+
+
+
+
+ Choose an artwork directory…
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -883,7 +895,7 @@ CA
-
+
diff --git a/TagTunes/Preferences.swift b/TagTunes/Preferences.swift
index 3e124ad..d648b79 100644
--- a/TagTunes/Preferences.swift
+++ b/TagTunes/Preferences.swift
@@ -32,6 +32,8 @@ import Cocoa
static let artworkTargetKey = "Artwork Target"
+ static let overwriteExistingFilesKey = "Overwrite Existing Files"
+
static let keepSearchResultsKey = "Keep Search Results"
static let removeSavedAlbumsKey = "Remove Saved Albums"
@@ -72,6 +74,7 @@ import Cocoa
public func initializeDefaultValues() {
NSUserDefaults.standardUserDefaults().registerDefaults([
UserDefaultsConstants.saveArtworkKey: false,
+ UserDefaultsConstants.overwriteExistingFilesKey: false,
UserDefaultsConstants.keepSearchResultsKey: false,
UserDefaultsConstants.removeSavedAlbumsKey: false,
UserDefaultsConstants.useLowResolutionArtworkKey: false,
@@ -113,6 +116,16 @@ import Cocoa
}
}
+ /// If `true` any existing files will be overwritten when artworks are saved.
+ public dynamic var overwriteExistingFiles: Bool {
+ set {
+ NSUserDefaults.standardUserDefaults().setBool(newValue, forKey: UserDefaultsConstants.overwriteExistingFilesKey)
+ }
+ get {
+ return NSUserDefaults.standardUserDefaults().boolForKey(UserDefaultsConstants.overwriteExistingFilesKey)
+ }
+ }
+
/// If `true` the search results are not removed from the main outline view
/// when the user selects a result.
public dynamic var keepSearchResults: Bool {