Delete invalid files when encountered
This commit is contained in:
parent
64354e7714
commit
1e38f083e0
1 changed files with 8 additions and 4 deletions
|
@ -183,7 +183,7 @@ class FileUploader {
|
|||
forcedUpload.toString());
|
||||
final asset = await file.getAsset();
|
||||
if (asset == null) {
|
||||
throw InvalidFileError();
|
||||
await _onInvalidFileError(file);
|
||||
}
|
||||
sourceFile = (await asset.originFile);
|
||||
var key;
|
||||
|
@ -211,9 +211,7 @@ class FileUploader {
|
|||
quality: 50,
|
||||
);
|
||||
if (thumbnailData == null) {
|
||||
_logger.severe("Could not generate thumbnail for " + file.toString());
|
||||
await FilesDB.instance.deleteLocalFile(file.localID);
|
||||
throw InvalidFileError();
|
||||
await _onInvalidFileError(file);
|
||||
}
|
||||
int compressionAttempts = 0;
|
||||
while (thumbnailData.length > THUMBNAIL_DATA_LIMIT &&
|
||||
|
@ -306,6 +304,12 @@ class FileUploader {
|
|||
}
|
||||
}
|
||||
|
||||
Future _onInvalidFileError(File file) async {
|
||||
_logger.severe("Invalid file encountered: " + file.toString());
|
||||
await FilesDB.instance.deleteLocalFile(file.localID);
|
||||
throw InvalidFileError();
|
||||
}
|
||||
|
||||
Future<File> _uploadFile(
|
||||
File file,
|
||||
int collectionID,
|
||||
|
|
Loading…
Add table
Reference in a new issue