|
|
@ -29,7 +29,7 @@ abstract class FilesBlocStates { |
|
|
|
class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocStates { |
|
|
|
class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocStates { |
|
|
|
FilesBloc( |
|
|
|
FilesBloc( |
|
|
|
this.options, |
|
|
|
this.options, |
|
|
|
this.client, |
|
|
|
this.account, |
|
|
|
this._requestManager, |
|
|
|
this._requestManager, |
|
|
|
this._platform, |
|
|
|
this._platform, |
|
|
|
) { |
|
|
|
) { |
|
|
@ -38,7 +38,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final FilesAppSpecificOptions options; |
|
|
|
final FilesAppSpecificOptions options; |
|
|
|
final NextcloudClient client; |
|
|
|
final Account account; |
|
|
|
final RequestManager _requestManager; |
|
|
|
final RequestManager _requestManager; |
|
|
|
final NeonPlatform _platform; |
|
|
|
final NeonPlatform _platform; |
|
|
|
late final browser = getNewFilesBrowserBloc(); |
|
|
|
late final browser = getNewFilesBrowserBloc(); |
|
|
@ -66,7 +66,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
@override |
|
|
|
@override |
|
|
|
void addFavorite(final List<String> path) { |
|
|
|
void addFavorite(final List<String> path) { |
|
|
|
wrapAction( |
|
|
|
wrapAction( |
|
|
|
() async => client.webdav.proppatch( |
|
|
|
() async => account.client.webdav.proppatch( |
|
|
|
path.join('/'), |
|
|
|
path.join('/'), |
|
|
|
set: WebDavProp(ocfavorite: 1), |
|
|
|
set: WebDavProp(ocfavorite: 1), |
|
|
|
), |
|
|
|
), |
|
|
@ -75,17 +75,17 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void copy(final List<String> path, final List<String> destination) { |
|
|
|
void copy(final List<String> path, final List<String> destination) { |
|
|
|
wrapAction(() async => client.webdav.copy(path.join('/'), destination.join('/'))); |
|
|
|
wrapAction(() async => account.client.webdav.copy(path.join('/'), destination.join('/'))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void delete(final List<String> path) { |
|
|
|
void delete(final List<String> path) { |
|
|
|
wrapAction(() async => client.webdav.delete(path.join('/'))); |
|
|
|
wrapAction(() async => account.client.webdav.delete(path.join('/'))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void move(final List<String> path, final List<String> destination) { |
|
|
|
void move(final List<String> path, final List<String> destination) { |
|
|
|
wrapAction(() async => client.webdav.move(path.join('/'), destination.join('/'))); |
|
|
|
wrapAction(() async => account.client.webdav.move(path.join('/'), destination.join('/'))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -124,7 +124,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
@override |
|
|
|
@override |
|
|
|
void removeFavorite(final List<String> path) { |
|
|
|
void removeFavorite(final List<String> path) { |
|
|
|
wrapAction( |
|
|
|
wrapAction( |
|
|
|
() async => client.webdav.proppatch( |
|
|
|
() async => account.client.webdav.proppatch( |
|
|
|
path.join('/'), |
|
|
|
path.join('/'), |
|
|
|
set: WebDavProp(ocfavorite: 0), |
|
|
|
set: WebDavProp(ocfavorite: 0), |
|
|
|
), |
|
|
|
), |
|
|
@ -134,7 +134,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
@override |
|
|
|
@override |
|
|
|
void rename(final List<String> path, final String name) { |
|
|
|
void rename(final List<String> path, final String name) { |
|
|
|
wrapAction( |
|
|
|
wrapAction( |
|
|
|
() async => client.webdav.move( |
|
|
|
() async => account.client.webdav.move( |
|
|
|
path.join('/'), |
|
|
|
path.join('/'), |
|
|
|
(path.sublist(0, path.length - 1)..add(name)).join('/'), |
|
|
|
(path.sublist(0, path.length - 1)..add(name)).join('/'), |
|
|
|
), |
|
|
|
), |
|
|
@ -148,7 +148,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
final file = File( |
|
|
|
final file = File( |
|
|
|
p.join( |
|
|
|
p.join( |
|
|
|
await _platform.getUserAccessibleAppDataPath(), |
|
|
|
await _platform.getUserAccessibleAppDataPath(), |
|
|
|
client.humanReadableID, |
|
|
|
account.humanReadableID, |
|
|
|
'files', |
|
|
|
'files', |
|
|
|
path.join(Platform.pathSeparator), |
|
|
|
path.join(Platform.pathSeparator), |
|
|
|
), |
|
|
|
), |
|
|
@ -175,7 +175,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
lastModified: stat.modified, |
|
|
|
lastModified: stat.modified, |
|
|
|
); |
|
|
|
); |
|
|
|
uploadTasks.add(uploadTasks.value..add(task)); |
|
|
|
uploadTasks.add(uploadTasks.value..add(task)); |
|
|
|
await _uploadQueue.add(() => task.execute(client, file.openRead())); |
|
|
|
await _uploadQueue.add(() => task.execute(account.client, file.openRead())); |
|
|
|
uploadTasks.add(uploadTasks.value..removeWhere((final t) => t == task)); |
|
|
|
uploadTasks.add(uploadTasks.value..removeWhere((final t) => t == task)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
disableTimeout: true, |
|
|
|
disableTimeout: true, |
|
|
@ -192,14 +192,14 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
path: path, |
|
|
|
path: path, |
|
|
|
); |
|
|
|
); |
|
|
|
downloadTasks.add(downloadTasks.value..add(task)); |
|
|
|
downloadTasks.add(downloadTasks.value..add(task)); |
|
|
|
await _downloadQueue.add(() => task.execute(client, sink)); |
|
|
|
await _downloadQueue.add(() => task.execute(account.client, sink)); |
|
|
|
downloadTasks.add(downloadTasks.value..removeWhere((final t) => t == task)); |
|
|
|
downloadTasks.add(downloadTasks.value..removeWhere((final t) => t == task)); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
await sink.close(); |
|
|
|
await sink.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(_requestManager, options, client); |
|
|
|
FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(_requestManager, options, account); |
|
|
|
|
|
|
|
|
|
|
|
void _downloadParalelismListener() { |
|
|
|
void _downloadParalelismListener() { |
|
|
|
_downloadQueue.parallel = options.downloadQueueParallelism.value; |
|
|
|
_downloadQueue.parallel = options.downloadQueueParallelism.value; |
|
|
|