Skip to content

Commit

Permalink
https://github.com/saoudrizwan/Disk/pull/66
Browse files Browse the repository at this point in the history
  • Loading branch information
craigrouse committed May 29, 2019
1 parent 27bed71 commit 56bc53c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Sources/Disk+InternalHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,16 @@ extension Disk {

/// Find an existing file's URL or throw an error if it doesn't exist
static func getExistingFileURL(for path: String?, in directory: Directory) throws -> URL {
do {
let url = try createURL(for: path, in: directory)
if FileManager.default.fileExists(atPath: url.path) {
return url
guard FileManager.default.fileExists(atPath: url.path) else {
throw createError(
.noFileFound,
description: "Could not find an existing file or folder at \(url.path).",
failureReason: "There is no existing file or folder at \(url.path)",
recoverySuggestion: "Check if a file or folder exists before trying to commit an operation on it."
)
}
throw createError(
.noFileFound,
description: "Could not find an existing file or folder at \(url.path).",
failureReason: "There is no existing file or folder at \(url.path)",
recoverySuggestion: "Check if a file or folder exists before trying to commit an operation on it."
)
} catch {
throw error
}
return url
}

/// Convert a user generated name to a valid file name
Expand Down

0 comments on commit 56bc53c

Please sign in to comment.