fix: icloud upload (#267)

This commit is contained in:
lollipopkit
2024-02-02 22:50:27 +08:00
parent 991189dbca
commit 4d78f1b11a

View File

@@ -71,20 +71,25 @@ abstract final class ICloud {
String? localPath, String? localPath,
}) async { }) async {
final completer = Completer<ICloudErr?>(); final completer = Completer<ICloudErr?>();
await ICloudStorage.download( try {
containerId: _containerId, await ICloudStorage.download(
relativePath: relativePath, containerId: _containerId,
destinationFilePath: localPath ?? '${await Paths.doc}/$relativePath', relativePath: relativePath,
onProgress: (stream) { destinationFilePath: localPath ?? '${await Paths.doc}/$relativePath',
stream.listen( onProgress: (stream) {
null, stream.listen(
onDone: () => completer.complete(null), null,
onError: (e) => completer.complete( onDone: () => completer.complete(null),
ICloudErr(type: ICloudErrType.generic, message: '$e'), onError: (e) => completer.complete(
), ICloudErr(type: ICloudErrType.generic, message: '$e'),
); ),
}, );
); },
);
} catch (e, s) {
_logger.warning('Download $relativePath failed', e, s);
completer.complete(ICloudErr(type: ICloudErrType.generic, message: '$e'));
}
return completer.future; return completer.future;
} }