@stepincto/expo-video 1.0.3 → 1.0.4
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.
|
@@ -42,7 +42,7 @@ class CachableRequest: Equatable, Hashable {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// 2. Acquire per-file lock
|
|
45
|
+
// 2. Acquire per-file lock (non-blocking)
|
|
46
46
|
let filePath = cachedResource.dataPath
|
|
47
47
|
let lock: NSLock = Self.fileLocksQueue.sync {
|
|
48
48
|
if let l = Self.fileLocks[filePath] { return l }
|
|
@@ -54,18 +54,22 @@ class CachableRequest: Equatable, Hashable {
|
|
|
54
54
|
// Another writer is active, skip this write
|
|
55
55
|
return
|
|
56
56
|
}
|
|
57
|
-
defer { lock.unlock() }
|
|
58
57
|
|
|
59
|
-
// 3.
|
|
58
|
+
// 3. Perform async write with final range check inside the task
|
|
60
59
|
let offset = dataOffset
|
|
61
60
|
let length = receivedData.count
|
|
62
61
|
let end = offset + Int64(length) - 1
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
|
|
63
|
+
Task.detached(priority: .userInitiated) { [receivedData] in
|
|
64
|
+
// Final check inside the async task to prevent race conditions
|
|
65
|
+
if cachedResource.canRespondWithData(from: offset, to: end) {
|
|
66
|
+
// This range is already cached, skip writing
|
|
67
|
+
lock.unlock()
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
68
71
|
await cachedResource.writeData(data: receivedData, offset: offset)
|
|
72
|
+
lock.unlock()
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stepincto/expo-video",
|
|
3
3
|
"title": "Expo Video",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"originalUpstreamVersion": "2.2.2",
|
|
6
6
|
"description": "A cross-platform, performant video component for React Native and Expo with Web support",
|
|
7
7
|
"main": "build/index.js",
|