expo-file-system 18.0.0 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 18.0.2 — 2024-11-11
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 18.0.1 — 2024-11-07
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [expo-file-system][next] Fix download function throwing an unexpected error if destination already exists. ([#32626](https://github.com/expo/expo/pull/32626) by [@aleqsio](https://github.com/aleqsio))
22
+
13
23
  ## 18.0.0 — 2024-10-22
14
24
 
15
25
  ### 🛠 Breaking changes
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '18.0.0'
4
+ version = '18.0.2'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.filesystem"
15
15
  defaultConfig {
16
16
  versionCode 30
17
- versionName "18.0.0"
17
+ versionName "18.0.2"
18
18
  }
19
19
  }
20
20
 
@@ -28,3 +28,8 @@ internal class InvalidPermissionException(permission: Permission) :
28
28
  CodedException(
29
29
  "Missing '${permission.name}' permission for accessing the file."
30
30
  )
31
+
32
+ internal class DestinationAlreadyExistsException :
33
+ CodedException(
34
+ "Destination already exists"
35
+ )
@@ -52,6 +52,10 @@ class FileSystemNextModule : Module() {
52
52
  to.file
53
53
  }
54
54
 
55
+ if (destination.exists()) {
56
+ throw DestinationAlreadyExistsException()
57
+ }
58
+
55
59
  val body = response.body ?: throw UnableToDownloadException("response body is null")
56
60
  body.byteStream().use { input ->
57
61
  FileOutputStream(destination).use { output ->
@@ -48,3 +48,9 @@ internal class UnableToCreateFileException: GenericException<String> {
48
48
  "Unable to create file: \(param)"
49
49
  }
50
50
  }
51
+
52
+ internal class DestinationAlreadyExistsException: Exception {
53
+ override var reason: String {
54
+ "Destination already exists"
55
+ }
56
+ }
@@ -33,17 +33,19 @@ public final class FileSystemNextModule: Module {
33
33
  }
34
34
 
35
35
  do {
36
+ let destination: URL
36
37
  if let to = to as? FileSystemDirectory {
37
38
  let filename = httpResponse.suggestedFilename ?? url.lastPathComponent
38
- let destination = to.url.appendingPathComponent(filename)
39
- try FileManager.default.copyItem(at: fileURL, to: to.url.appendingPathComponent(filename))
40
- // TODO: Remove .url.absoluteString once returning shared objects works
41
- promise.resolve(FileSystemFile(url: destination).url.absoluteString)
39
+ destination = to.url.appendingPathComponent(filename)
42
40
  } else {
43
- try FileManager.default.moveItem(at: fileURL, to: to.url)
44
- // TODO: Remove .url.absoluteString once returning shared objects works
45
- promise.resolve(to.url.absoluteString)
41
+ destination = to.url
46
42
  }
43
+ if FileManager.default.fileExists(atPath: destination.path) {
44
+ throw DestinationAlreadyExistsException()
45
+ }
46
+ try FileManager.default.moveItem(at: fileURL, to: destination)
47
+ // TODO: Remove .url.absoluteString once returning shared objects works
48
+ promise.resolve(destination.absoluteString)
47
49
  } catch {
48
50
  promise.reject(error)
49
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-file-system",
3
- "version": "18.0.0",
3
+ "version": "18.0.2",
4
4
  "description": "Provides access to the local file system on the device.",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -36,11 +36,11 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "expo-module-scripts": "^4.0.0",
39
- "jest-expo": "~52.0.0-preview.0"
39
+ "jest-expo": "~52.0.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "expo": "*",
43
43
  "react-native": "*"
44
44
  },
45
- "gitHead": "7c7d2362fff23bec26cd145ed34edd9c403551bd"
45
+ "gitHead": "8f11fad6f46b878de4746b49b18599fc57b5729f"
46
46
  }