Skip to content

Commit 4f26cf6

Browse files
committed
fix: saving ParseFiles locally do not throw error
1 parent 23cebdf commit 4f26cf6

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
### 4.9.3
88
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.9.2...4.9.3)
9+
910
__Fixes__
11+
- When saving ParseFiles locally, files that have a directory in their filename save correctly instead of throwing an error on the client ([#399](https://github.com/parse-community/Parse-Swift/pull/399)), thanks to [Corey Baker](https://github.com/cbaker6).
1012
- Default to not setting kSecUseDataProtectionKeychain to true as this can cause issues with querying the Keychain in Swift Playgrounds or other apps that cannot setup the Keychain on macOS. This behavior can be changed by setting usingDataProtectionKeychain to true when initializing the SDK ([#398](https://github.com/parse-community/Parse-Swift/pull/398)), thanks to [Corey Baker](https://github.com/cbaker6).
1113

1214
### 4.9.2

Sources/ParseSwift/API/API+Command.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,8 @@ internal extension API.Command {
365365
let downloadDirectoryPath = defaultDirectoryPath
366366
.appendingPathComponent(ParseConstants.fileDownloadsDirectory, isDirectory: true)
367367
try fileManager.createDirectoryIfNeeded(downloadDirectoryPath.relativePath)
368-
guard let fileNameSubstring = object.name.split(separator: "/").last else {
369-
throw ParseError(code: .unknownError, message: "Cannot get file name")
370-
}
371-
let fileLocation = downloadDirectoryPath.appendingPathComponent(String(fileNameSubstring))
368+
let fileNameURL = URL(fileURLWithPath: object.name)
369+
let fileLocation = downloadDirectoryPath.appendingPathComponent(fileNameURL.lastPathComponent)
372370
if tempFileLocation != fileLocation {
373371
try? FileManager.default.removeItem(at: fileLocation) // Remove file if it is already present
374372
try FileManager.default.moveItem(at: tempFileLocation, to: fileLocation)

Sources/ParseSwift/ParseConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
enum ParseConstants {
1212
static let sdk = "swift"
13-
static let version = "4.9.2"
13+
static let version = "4.9.3"
1414
static let fileManagementDirectory = "parse/"
1515
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
1616
static let fileManagementLibraryDirectory = "Library/"

0 commit comments

Comments
 (0)