File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6383,6 +6383,11 @@ class PluginBridgeAdapter {
63836383 },
63846384 );
63856385 _mobilePdfExport = operation;
6386+ final stopRevocationListener =
6387+ PluginRegistryRepository .onPendingFileAccessRevoked (
6388+ plugin.pluginId,
6389+ () => unawaited (_cancelMobilePdfExport (operation)),
6390+ );
63866391 try {
63876392 // Cancel acknowledgement cannot release a file still held by UIKit.
63886393 final result = await operation.result;
@@ -6412,6 +6417,7 @@ class PluginBridgeAdapter {
64126417 }
64136418 return {'saved' : false , 'name' : null };
64146419 } finally {
6420+ stopRevocationListener ();
64156421 if (identical (_mobilePdfExport, operation)) _mobilePdfExport = null ;
64166422 }
64176423 }
Original file line number Diff line number Diff line change @@ -189,14 +189,30 @@ class PluginRegistryRepository {
189189 }
190190
191191 static final Map <String , int > _fileAccessGenerations = {};
192+ static final _fileAccessRevocations = < String , Set <void Function ()>> {};
192193
193194 /// דור הביטול משותף לכל מופעי התוסף, גם כשההרשאה בוטלה מחוץ לגשר.
194195 static int fileAccessGenerationForPlugin (String pluginId) =>
195196 _fileAccessGenerations[pluginId] ?? 0 ;
196197
198+ /// רושם בקשת ביטול רק למשך פעולה שממתינה לתוצאה מחוץ לגשר.
199+ static void Function () onPendingFileAccessRevoked (
200+ String pluginId,
201+ void Function () cancel,
202+ ) {
203+ final callbacks = _fileAccessRevocations.putIfAbsent (pluginId, () => {});
204+ callbacks.add (cancel);
205+ return () {
206+ if (! identical (_fileAccessRevocations[pluginId], callbacks)) return ;
207+ callbacks.remove (cancel);
208+ if (callbacks.isEmpty) _fileAccessRevocations.remove (pluginId);
209+ };
210+ }
211+
197212 static void revokePendingFileAccess (String pluginId) {
198213 _fileAccessGenerations[pluginId] =
199214 fileAccessGenerationForPlugin (pluginId) + 1 ;
215+ _fileAccessRevocations.remove (pluginId)? .forEach ((cancel) => cancel ());
200216 }
201217
202218 Future <void > setPermission (
Original file line number Diff line number Diff line change @@ -745,6 +745,32 @@ void main() {
745745 });
746746 }
747747
748+ testWidgets ('שלילת הרשאה מבקשת ביטול ושומרת staging עד תוצאת iOS' , (
749+ tester,
750+ ) async {
751+ await open (tester);
752+ var completed = false ;
753+ final result = start ()..then <void >((_) => completed = true );
754+ await _waitForMobile (tester, () => backend.requests.length == 1 );
755+ final request = backend.requests.single;
756+
757+ PluginRegistryRepository .revokePendingFileAccess ('another.plugin' );
758+ await tester.pump ();
759+ expect (backend.cancellations, isEmpty);
760+ PluginRegistryRepository .revokePendingFileAccess ('test.plugin' );
761+ await _waitForMobile (tester, () => backend.cancellations.length == 1 );
762+ expect (backend.cancellations, [request.operationId]);
763+ expect (completed, isFalse);
764+ expect (File (request.sourcePath).existsSync (), isTrue);
765+
766+ backend.complete (MobilePdfExportStatus .cancelled);
767+ expect (await _settleMobile (tester, result), {
768+ 'saved' : false ,
769+ 'name' : null ,
770+ });
771+ expect (File (request.sourcePath).existsSync (), isFalse);
772+ });
773+
748774 testWidgets ('שארית אחרי dispose מוזהרת למשתמש בלי URI בתשובת RPC' , (
749775 tester,
750776 ) async {
You can’t perform that action at this time.
0 commit comments