Skip to content

Commit

Permalink
Only deleteItem if file exists at path.
Browse files Browse the repository at this point in the history
  • Loading branch information
babbage committed Apr 7, 2018
1 parent fae6734 commit 23e1174
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FBSnapshotsViewer/Extensions/FileManager+Move.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import Foundation

extension FileManager {
func moveItem(at fromURL: URL, to toURL: URL) throws {
if fileExists(atPath: toURL.path) {
try self.removeItem(at: toURL)
}
try deleteItem(at: fromURL)
try self.copyItem(at: fromURL, to: toURL)
}

func deleteItem(at url: URL) throws {
if fileExists(atPath: url.path) {
try self.removeItem(at: url)
}
}
}

0 comments on commit 23e1174

Please sign in to comment.