From 9648aec3b5cc6771d1cc69bd39a69a0e743119bb Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 26 Dec 2016 15:52:58 -0600 Subject: [PATCH] Fixes issue where importing zipped games from Safari failed Failed because app attempted to extract the game into the containing folder, which in this case was read-only. Fixed by extracting to temporary directory instead. --- Delta/Database/DatabaseManager.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Delta/Database/DatabaseManager.swift b/Delta/Database/DatabaseManager.swift index 8c492d5..0239fc6 100644 --- a/Delta/Database/DatabaseManager.swift +++ b/Delta/Database/DatabaseManager.swift @@ -260,7 +260,8 @@ extension DatabaseManager // ROMs may potentially be very large, so we extract using file streams and not raw Data let inputStream = try entry.newStream() - let outputURL = url.deletingLastPathComponent().appendingPathComponent(entry.fileName) + // Must use temporary directory, and not the directory containing zip file, since the latter might be read-only (such as when importing from Safari) + let outputURL = FileManager.default.temporaryDirectory.appendingPathComponent(entry.fileName) if FileManager.default.fileExists(atPath: outputURL.path) {