@react-native-firebase/storage 26.4.0 → 27.0.0
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 +15 -0
- package/RNFBStorage.podspec +9 -4
- package/android/build.gradle +3 -0
- package/android/src/main/java/io/invertase/firebase/storage/RNFBStorageTaskRegistry.kt +88 -0
- package/android/src/test/java/io/invertase/firebase/storage/RNFBStorageTaskRegistryTest.java +25 -0
- package/dist/module/index.js +1 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/index.d.ts +1 -1
- package/dist/typescript/lib/types/internal.d.ts +2 -3
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/ios/RNFBStorage/RNFBStorageCommon.m +17 -98
- package/ios/RNFBStorage/RNFBStorageErrorCodeMapper.swift +122 -0
- package/ios/RNFBStorage/RNFBStorageErrorSnapshotDictBuilder.swift +70 -0
- package/ios/RNFBStorage/RNFBStorageTaskRegistry.m +28 -35
- package/ios/RNFBStorage/RNFBStorageTaskRegistryStorage.swift +87 -0
- package/ios/RNFBStorage/RNFBStorageTaskStatusMapper.swift +57 -0
- package/ios/RNFBStorage.xcodeproj/project.pbxproj +26 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageErrorCodeMapperFacadeTests.m +91 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageErrorCodeMapperTests.swift +211 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageErrorSnapshotDictBuilderFacadeTests.m +125 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageTaskRegistryStorageTests.swift +154 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageTaskStatusMapperFacadeTests.m +52 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageTaskStatusMapperTests.swift +58 -0
- package/ios/RNFBStorageUnitTests/RNFBStorageUnitTests.xcodeproj/project.pbxproj +50 -0
- package/lib/index.ts +1 -1
- package/lib/types/internal.ts +5 -4
- package/lib/version.ts +1 -1
- package/package.json +4 -4
- package/android/src/main/java/io/invertase/firebase/storage/RNFBStorageTaskRegistry.java +0 -93
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
E7000000000000000000000B /* RNFBStorageTaskRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000018 /* RNFBStorageTaskRegistry.m */; };
|
|
12
12
|
E7000000000000000000000C /* RNFBStorageTaskRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000009 /* RNFBStorageTaskRegistryTests.m */; };
|
|
13
13
|
E70000000000000000000015 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E70000000000000000000014 /* XCTest.framework */; };
|
|
14
|
+
E70000000000000000000019 /* RNFBHandleMapStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7000000000000000000001C /* RNFBHandleMapStorage.swift */; };
|
|
15
|
+
E7000000000000000000001D /* RNFBStorageTaskRegistryStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7000000000000000000001E /* RNFBStorageTaskRegistryStorage.swift */; };
|
|
16
|
+
E7000000000000000000001F /* RNFBStorageTaskRegistryStorageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000020 /* RNFBStorageTaskRegistryStorageTests.swift */; };
|
|
17
|
+
E70000000000000000000021 /* RNFBStorageTaskStatusMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000022 /* RNFBStorageTaskStatusMapper.swift */; };
|
|
18
|
+
E70000000000000000000023 /* RNFBStorageTaskStatusMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000024 /* RNFBStorageTaskStatusMapperTests.swift */; };
|
|
19
|
+
E70000000000000000000025 /* RNFBStorageTaskStatusMapperFacadeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000026 /* RNFBStorageTaskStatusMapperFacadeTests.m */; };
|
|
20
|
+
E70000000000000000000027 /* RNFBStorageErrorCodeMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000028 /* RNFBStorageErrorCodeMapper.swift */; };
|
|
21
|
+
E70000000000000000000029 /* RNFBStorageErrorCodeMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7000000000000000000002A /* RNFBStorageErrorCodeMapperTests.swift */; };
|
|
22
|
+
E7000000000000000000002B /* RNFBStorageErrorCodeMapperFacadeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7000000000000000000002C /* RNFBStorageErrorCodeMapperFacadeTests.m */; };
|
|
23
|
+
E7000000000000000000002D /* RNFBStorageErrorSnapshotDictBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7000000000000000000002E /* RNFBStorageErrorSnapshotDictBuilder.swift */; };
|
|
24
|
+
E7000000000000000000002F /* RNFBStorageErrorSnapshotDictBuilderFacadeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E70000000000000000000030 /* RNFBStorageErrorSnapshotDictBuilderFacadeTests.m */; };
|
|
14
25
|
/* End PBXBuildFile section */
|
|
15
26
|
|
|
16
27
|
/* Begin PBXFileReference section */
|
|
@@ -21,6 +32,17 @@
|
|
|
21
32
|
E70000000000000000000016 /* RNFBStorageTaskRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNFBStorageTaskRegistry.h; path = ../RNFBStorage/RNFBStorageTaskRegistry.h; sourceTree = SOURCE_ROOT; };
|
|
22
33
|
E70000000000000000000018 /* RNFBStorageTaskRegistry.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RNFBStorageTaskRegistry.m; path = ../RNFBStorage/RNFBStorageTaskRegistry.m; sourceTree = SOURCE_ROOT; };
|
|
23
34
|
E70000000000000000000014 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
|
35
|
+
E7000000000000000000001C /* RNFBHandleMapStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RNFBHandleMapStorage.swift; path = ../../../app/ios/RNFBApp/RNFBHandleMapStorage.swift; sourceTree = SOURCE_ROOT; };
|
|
36
|
+
E7000000000000000000001E /* RNFBStorageTaskRegistryStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RNFBStorageTaskRegistryStorage.swift; path = ../RNFBStorage/RNFBStorageTaskRegistryStorage.swift; sourceTree = SOURCE_ROOT; };
|
|
37
|
+
E70000000000000000000020 /* RNFBStorageTaskRegistryStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNFBStorageTaskRegistryStorageTests.swift; sourceTree = "<group>"; };
|
|
38
|
+
E70000000000000000000022 /* RNFBStorageTaskStatusMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RNFBStorageTaskStatusMapper.swift; path = ../RNFBStorage/RNFBStorageTaskStatusMapper.swift; sourceTree = SOURCE_ROOT; };
|
|
39
|
+
E70000000000000000000024 /* RNFBStorageTaskStatusMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNFBStorageTaskStatusMapperTests.swift; sourceTree = "<group>"; };
|
|
40
|
+
E70000000000000000000026 /* RNFBStorageTaskStatusMapperFacadeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNFBStorageTaskStatusMapperFacadeTests.m; sourceTree = "<group>"; };
|
|
41
|
+
E70000000000000000000028 /* RNFBStorageErrorCodeMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RNFBStorageErrorCodeMapper.swift; path = ../RNFBStorage/RNFBStorageErrorCodeMapper.swift; sourceTree = SOURCE_ROOT; };
|
|
42
|
+
E7000000000000000000002A /* RNFBStorageErrorCodeMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNFBStorageErrorCodeMapperTests.swift; sourceTree = "<group>"; };
|
|
43
|
+
E7000000000000000000002C /* RNFBStorageErrorCodeMapperFacadeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNFBStorageErrorCodeMapperFacadeTests.m; sourceTree = "<group>"; };
|
|
44
|
+
E7000000000000000000002E /* RNFBStorageErrorSnapshotDictBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RNFBStorageErrorSnapshotDictBuilder.swift; path = ../RNFBStorage/RNFBStorageErrorSnapshotDictBuilder.swift; sourceTree = SOURCE_ROOT; };
|
|
45
|
+
E70000000000000000000030 /* RNFBStorageErrorSnapshotDictBuilderFacadeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNFBStorageErrorSnapshotDictBuilderFacadeTests.m; sourceTree = "<group>"; };
|
|
24
46
|
/* End PBXFileReference section */
|
|
25
47
|
|
|
26
48
|
/* Begin PBXFrameworksBuildPhase section */
|
|
@@ -56,9 +78,20 @@
|
|
|
56
78
|
children = (
|
|
57
79
|
E70000000000000000000007 /* RNFBHandleMap.h */,
|
|
58
80
|
E70000000000000000000008 /* RNFBHandleMap.m */,
|
|
81
|
+
E7000000000000000000001C /* RNFBHandleMapStorage.swift */,
|
|
59
82
|
E70000000000000000000016 /* RNFBStorageTaskRegistry.h */,
|
|
60
83
|
E70000000000000000000018 /* RNFBStorageTaskRegistry.m */,
|
|
84
|
+
E7000000000000000000001E /* RNFBStorageTaskRegistryStorage.swift */,
|
|
61
85
|
E70000000000000000000009 /* RNFBStorageTaskRegistryTests.m */,
|
|
86
|
+
E70000000000000000000020 /* RNFBStorageTaskRegistryStorageTests.swift */,
|
|
87
|
+
E70000000000000000000022 /* RNFBStorageTaskStatusMapper.swift */,
|
|
88
|
+
E70000000000000000000024 /* RNFBStorageTaskStatusMapperTests.swift */,
|
|
89
|
+
E70000000000000000000026 /* RNFBStorageTaskStatusMapperFacadeTests.m */,
|
|
90
|
+
E70000000000000000000028 /* RNFBStorageErrorCodeMapper.swift */,
|
|
91
|
+
E7000000000000000000002A /* RNFBStorageErrorCodeMapperTests.swift */,
|
|
92
|
+
E7000000000000000000002C /* RNFBStorageErrorCodeMapperFacadeTests.m */,
|
|
93
|
+
E7000000000000000000002E /* RNFBStorageErrorSnapshotDictBuilder.swift */,
|
|
94
|
+
E70000000000000000000030 /* RNFBStorageErrorSnapshotDictBuilderFacadeTests.m */,
|
|
62
95
|
);
|
|
63
96
|
name = Sources;
|
|
64
97
|
sourceTree = "<group>";
|
|
@@ -121,8 +154,19 @@
|
|
|
121
154
|
buildActionMask = 2147483647;
|
|
122
155
|
files = (
|
|
123
156
|
E7000000000000000000000A /* RNFBHandleMap.m in Sources */,
|
|
157
|
+
E70000000000000000000019 /* RNFBHandleMapStorage.swift in Sources */,
|
|
158
|
+
E7000000000000000000001D /* RNFBStorageTaskRegistryStorage.swift in Sources */,
|
|
124
159
|
E7000000000000000000000B /* RNFBStorageTaskRegistry.m in Sources */,
|
|
125
160
|
E7000000000000000000000C /* RNFBStorageTaskRegistryTests.m in Sources */,
|
|
161
|
+
E7000000000000000000001F /* RNFBStorageTaskRegistryStorageTests.swift in Sources */,
|
|
162
|
+
E70000000000000000000021 /* RNFBStorageTaskStatusMapper.swift in Sources */,
|
|
163
|
+
E70000000000000000000023 /* RNFBStorageTaskStatusMapperTests.swift in Sources */,
|
|
164
|
+
E70000000000000000000025 /* RNFBStorageTaskStatusMapperFacadeTests.m in Sources */,
|
|
165
|
+
E70000000000000000000027 /* RNFBStorageErrorCodeMapper.swift in Sources */,
|
|
166
|
+
E70000000000000000000029 /* RNFBStorageErrorCodeMapperTests.swift in Sources */,
|
|
167
|
+
E7000000000000000000002B /* RNFBStorageErrorCodeMapperFacadeTests.m in Sources */,
|
|
168
|
+
E7000000000000000000002D /* RNFBStorageErrorSnapshotDictBuilder.swift in Sources */,
|
|
169
|
+
E7000000000000000000002F /* RNFBStorageErrorSnapshotDictBuilderFacadeTests.m in Sources */,
|
|
126
170
|
);
|
|
127
171
|
runOnlyForDeploymentPostprocessing = 0;
|
|
128
172
|
};
|
|
@@ -171,6 +215,7 @@
|
|
|
171
215
|
CODE_SIGNING_REQUIRED = NO;
|
|
172
216
|
CODE_SIGN_IDENTITY = "-";
|
|
173
217
|
COMBINE_HIDPI_IMAGES = YES;
|
|
218
|
+
DEFINES_MODULE = YES;
|
|
174
219
|
GENERATE_INFOPLIST_FILE = YES;
|
|
175
220
|
HEADER_SEARCH_PATHS = (
|
|
176
221
|
"$(SRCROOT)/../../../app/ios",
|
|
@@ -194,6 +239,8 @@
|
|
|
194
239
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
195
240
|
SDKROOT = macosx;
|
|
196
241
|
SUPPORTED_PLATFORMS = macosx;
|
|
242
|
+
SWIFT_OBJC_INTERFACE_HEADER_NAME = "RNFBHandleMapStorage-Swift.inc";
|
|
243
|
+
SWIFT_VERSION = 5.10;
|
|
197
244
|
};
|
|
198
245
|
name = Debug;
|
|
199
246
|
};
|
|
@@ -205,6 +252,7 @@
|
|
|
205
252
|
CODE_SIGNING_REQUIRED = NO;
|
|
206
253
|
CODE_SIGN_IDENTITY = "-";
|
|
207
254
|
COMBINE_HIDPI_IMAGES = YES;
|
|
255
|
+
DEFINES_MODULE = YES;
|
|
208
256
|
GENERATE_INFOPLIST_FILE = YES;
|
|
209
257
|
HEADER_SEARCH_PATHS = (
|
|
210
258
|
"$(SRCROOT)/../../../app/ios",
|
|
@@ -221,6 +269,8 @@
|
|
|
221
269
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
222
270
|
SDKROOT = macosx;
|
|
223
271
|
SUPPORTED_PLATFORMS = macosx;
|
|
272
|
+
SWIFT_OBJC_INTERFACE_HEADER_NAME = "RNFBHandleMapStorage-Swift.inc";
|
|
273
|
+
SWIFT_VERSION = 5.10;
|
|
224
274
|
};
|
|
225
275
|
name = Release;
|
|
226
276
|
};
|
package/lib/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type { FirebaseApp } from '@react-native-firebase/app';
|
|
|
20
20
|
import {
|
|
21
21
|
FirebaseModule,
|
|
22
22
|
getOrCreateModularInstance,
|
|
23
|
+
setReactNativeModule,
|
|
23
24
|
} from '@react-native-firebase/app/dist/module/internal';
|
|
24
25
|
import type { ModuleConfig } from '@react-native-firebase/app/dist/module/internal';
|
|
25
26
|
import type { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
@@ -27,7 +28,6 @@ import Reference from './StorageReference';
|
|
|
27
28
|
import { getGsUrlParts, getHttpUrlParts, handleStorageEvent } from './utils';
|
|
28
29
|
import { version } from './version';
|
|
29
30
|
import fallBackModule from './web/RNFBStorageModule';
|
|
30
|
-
import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
31
31
|
import './types/internal';
|
|
32
32
|
import type {
|
|
33
33
|
EmulatorMockTokenOptions,
|
package/lib/types/internal.ts
CHANGED
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
ModuleConfig,
|
|
20
|
+
ReactNativeFirebaseEventEmitter,
|
|
21
|
+
} from '@react-native-firebase/app/dist/module/types/internal';
|
|
19
22
|
import type {
|
|
20
23
|
FirebaseStorage,
|
|
21
24
|
StorageReference,
|
|
@@ -28,8 +31,6 @@ import type {
|
|
|
28
31
|
ListResult,
|
|
29
32
|
ListOptions,
|
|
30
33
|
} from './storage';
|
|
31
|
-
import type EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
|
32
|
-
|
|
33
34
|
/**
|
|
34
35
|
* Internal Storage type with access to private properties.
|
|
35
36
|
* Used internally by StorageReference and other internal classes.
|
|
@@ -37,7 +38,7 @@ import type EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitte
|
|
|
37
38
|
export type StorageInternal = FirebaseStorage & {
|
|
38
39
|
native: NativeRNFBTurboStorage;
|
|
39
40
|
_customUrlOrRegion: string | null;
|
|
40
|
-
emitter:
|
|
41
|
+
emitter: ReactNativeFirebaseEventEmitter;
|
|
41
42
|
eventNameForApp: (...args: Array<string | number>) => string;
|
|
42
43
|
_config: ModuleConfig;
|
|
43
44
|
/**
|
package/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '27.0.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Firebase - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.",
|
|
6
6
|
"main": "./dist/module/index.js",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"download"
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@react-native-firebase/app": "
|
|
52
|
+
"@react-native-firebase/app": "27.0.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public",
|
|
56
56
|
"provenance": true
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@react-native-firebase/app": "
|
|
59
|
+
"@react-native-firebase/app": "27.0.0",
|
|
60
60
|
"react-native-builder-bob": "^0.41.0"
|
|
61
61
|
},
|
|
62
62
|
"exports": {
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"node_modules/",
|
|
90
90
|
"dist/"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "0c7e942bca361f1765abaf233bf447d795718eff"
|
|
93
93
|
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.storage;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import io.invertase.firebase.common.RNFBHandleCollisionException;
|
|
21
|
-
import io.invertase.firebase.common.RNFBHandleMap;
|
|
22
|
-
import java.util.List;
|
|
23
|
-
import java.util.function.Predicate;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Pending upload/download task map. Unique {@link #put}; callers {@link #take} or {@link
|
|
27
|
-
* #takeAllAndCancel} then cancel outside the HandleMap lock.
|
|
28
|
-
*/
|
|
29
|
-
final class RNFBStorageTaskRegistry {
|
|
30
|
-
private final RNFBHandleMap<Integer, StoragePendingHandle> map = new RNFBHandleMap<>();
|
|
31
|
-
|
|
32
|
-
void put(int taskId, StoragePendingHandle handle) throws RNFBHandleCollisionException {
|
|
33
|
-
map.put(taskId, handle);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Unique put. On collision, {@code cancel()} the incoming handle and leave the existing mapping.
|
|
38
|
-
*
|
|
39
|
-
* @return true if stored
|
|
40
|
-
*/
|
|
41
|
-
boolean putOrDiscard(int taskId, StoragePendingHandle handle) {
|
|
42
|
-
if (map.putIfAbsent(taskId, handle)) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
if (handle != null) {
|
|
46
|
-
handle.cancel();
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
StoragePendingHandle get(int taskId) {
|
|
52
|
-
return map.get(taskId);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
StoragePendingHandle take(int taskId) {
|
|
56
|
-
return map.take(taskId);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
StoragePendingHandle takeIf(int taskId, Predicate<StoragePendingHandle> shouldTake) {
|
|
60
|
-
return map.takeIf(taskId, shouldTake);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Cancel outside the HandleMap lock; remove the mapping only when cancel succeeds. Returns {@code
|
|
65
|
-
* false} when no mapping existed or cancel failed. Trailing unregister is identity-gated so a
|
|
66
|
-
* replacement put after {@code cancel()} (e.g. production {@code destroyTask}) is not stolen.
|
|
67
|
-
*
|
|
68
|
-
* <p>Shape: get → cancel → identity takeIf on success (keep mapping when cancel returns false).
|
|
69
|
-
* iOS registry mirrors get → cancel → identity takeIf, but FIRStorage cancel is void so there is
|
|
70
|
-
* no keep-on-false path — see {@code RNFBStorageTaskRegistry.takeAndCancel:} / helper {@code
|
|
71
|
-
* setTaskStatus}.
|
|
72
|
-
*/
|
|
73
|
-
boolean takeAndCancel(int taskId) {
|
|
74
|
-
StoragePendingHandle handle = map.get(taskId);
|
|
75
|
-
if (handle == null) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
boolean cancelled = handle.cancel();
|
|
79
|
-
if (cancelled) {
|
|
80
|
-
map.takeIf(taskId, h -> h == handle);
|
|
81
|
-
}
|
|
82
|
-
return cancelled;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
void takeAllAndCancel() {
|
|
86
|
-
List<StoragePendingHandle> remaining = map.takeAll();
|
|
87
|
-
for (StoragePendingHandle handle : remaining) {
|
|
88
|
-
if (handle != null) {
|
|
89
|
-
handle.cancel();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|