|
@@ -392,6 +392,29 @@ class CollectionsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Future<void> trashEmptyCollections(Collection collection) async {
|
|
|
+ try {
|
|
|
+ // While trashing empty albums, we must pass keeFiles flag as True.
|
|
|
+ // The server will verify that the collection is actually empty before
|
|
|
+ // deleting the files. If keepFiles is set as False and the collection
|
|
|
+ // is not empty, then the files in the collections will be moved to trash
|
|
|
+ await _enteDio.delete(
|
|
|
+ "/collections/v3/${collection.id}?keepFiles=True&collectionID=${collection.id}",
|
|
|
+ );
|
|
|
+ final deletedCollection = collection.copyWith(isDeleted: true);
|
|
|
+ _collectionIDToCollections[collection.id] = deletedCollection;
|
|
|
+ unawaited(_db.insert([deletedCollection]));
|
|
|
+ } on DioError catch (e) {
|
|
|
+ if (e.response != null) {
|
|
|
+ debugPrint("Error " + e.response!.toString());
|
|
|
+ }
|
|
|
+ rethrow;
|
|
|
+ } catch (e) {
|
|
|
+ _logger.severe('failed to trash empty collection', e);
|
|
|
+ rethrow;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Future<void> _handleCollectionDeletion(Collection collection) async {
|
|
|
await _filesDB.deleteCollection(collection.id);
|
|
|
final deletedCollection = collection.copyWith(isDeleted: true);
|