Skip to content

Commit 085f5ad

Browse files
authored
feat: add ParseFile caching using download folder (#416)
* deprecate ParseCloud for ParseCloudable * update project * more pros updates * add ParseFileManager helpers * add caching and tests
1 parent e54a22c commit 085f5ad

33 files changed

+513
-272
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.13.1...main)
4+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.14.0...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 4.14.0
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.13.1...4.14.0)
9+
10+
__New features__
11+
- Add file caching using the Parse download folder ([#416](https://github.com/parse-community/Parse-Swift/pull/416)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
### 4.13.1
814
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.13.0...4.13.1)
915

ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,38 @@ import ParseSwift
1313
PlaygroundPage.current.needsIndefiniteExecution = true
1414
initializeParse()
1515

16-
//: Create your own value typed `ParseCloud` type.
17-
struct Hello: ParseCloud {
16+
//: Create your own value typed `ParseCloudable` type.
17+
struct Hello: ParseCloudable {
1818

1919
//: Return type of your Cloud Function
2020
typealias ReturnType = String
2121

22-
//: These are required by `ParseCloud`, you can set the default value to make it easier
22+
//: These are required by `ParseCloudable`, you can set the default value to make it easier
2323
//: to use.
2424
var functionJobName: String = "hello"
2525
}
2626

27-
//: Create another `ParseCloud` type.
28-
struct TestCloudCode: ParseCloud {
27+
//: Create another `ParseCloudable` type.
28+
struct TestCloudCode: ParseCloudable {
2929

3030
//: Return type of your Cloud Function
3131
typealias ReturnType = [String: Int]
3232

33-
//: These are required by `ParseCloud`, you can set the default value to make it easier
33+
//: These are required by `ParseCloudable`, you can set the default value to make it easier
3434
//: to use.
3535
var functionJobName: String = "testCloudCode"
3636

3737
//: If your cloud function takes arguments, they can be passed by creating properties:
3838
var argument1: [String: Int]
3939
}
4040

41-
//: Create another `ParseCloud` type.
42-
struct TestCloudCodeError: ParseCloud {
41+
//: Create another `ParseCloudable` type.
42+
struct TestCloudCodeError: ParseCloudable {
4343

4444
//: Return type of your Cloud Function
4545
typealias ReturnType = String
4646

47-
//: These are required by `ParseCloud`, you can set the default value to make it easier
47+
//: These are required by `ParseCloudable`, you can set the default value to make it easier
4848
//: to use.
4949
var functionJobName: String = "testCloudCodeError"
5050
}

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 63 additions & 55 deletions
Large diffs are not rendered by default.

ParseSwift.xcodeproj/xcshareddata/xcschemes/ParseSwift (iOS).xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1210"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ParseSwift.xcodeproj/xcshareddata/xcschemes/ParseSwift (macOS).xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1210"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ParseSwift.xcodeproj/xcshareddata/xcschemes/ParseSwift (tvOS).xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1210"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ParseSwift.xcodeproj/xcshareddata/xcschemes/ParseSwift (watchOS).xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1210"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ParseSwift.xcodeproj/xcshareddata/xcschemes/TestHost.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ParseSwift.xcodeproj/xcshareddata/xcschemes/TestHostTV.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/ParseSwift/API/API+Command.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,10 @@ internal extension API.Command {
358358
parseURL: object.url,
359359
otherURL: object.cloudURL) { (data) -> ParseFile in
360360
let tempFileLocation = try ParseCoding.jsonDecoder().decode(URL.self, from: data)
361-
guard let fileManager = ParseFileManager(),
362-
let defaultDirectoryPath = fileManager.defaultDataDirectoryPath else {
361+
guard let fileManager = ParseFileManager() else {
363362
throw ParseError(code: .unknownError, message: "Cannot create fileManager")
364363
}
365-
let downloadDirectoryPath = defaultDirectoryPath
366-
.appendingPathComponent(ParseConstants.fileDownloadsDirectory, isDirectory: true)
364+
let downloadDirectoryPath = try ParseFileManager.downloadDirectory()
367365
try fileManager.createDirectoryIfNeeded(downloadDirectoryPath.relativePath)
368366
let fileNameURL = URL(fileURLWithPath: object.name)
369367
let fileLocation = downloadDirectoryPath.appendingPathComponent(fileNameURL.lastPathComponent)

0 commit comments

Comments
 (0)