-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
download error if file exists #620
Comments
This error is also happening on Android when the file is in the directory but I'm trying to download it using the downloader. @hnvn do you think there's a better solution for this? I think it's better to append a duplication number to the file name |
Same problem here, sound nice if you fix this. I agree too, about append a duplication number when the filename is the same |
Create unique locale file with the remote file name: gist import 'dart:io';
import 'package:path/path.dart' as path;
class FileUtil {
static File getUniqueFile(String folderName, final String? fileName) {
int num = 1;
String destFileName =
fileName ?? '${DateTime.now().millisecondsSinceEpoch}';
String extension = path.extension(destFileName);
String baseName = path.basenameWithoutExtension(destFileName);
File file = File(folderName + path.separator + destFileName);
while (file.existsSync()) {
destFileName = '$baseName (${num++})$extension';
file = File(folderName + path.separator + destFileName);
}
return file;
}
static Future<File> createUniqueFile(
String folderName, final String? name) async {
File uniqueFile = FileUtil.getUniqueFile(folderName, name);
if (!uniqueFile.existsSync()) {
await uniqueFile.create();
}
return uniqueFile;
}
} |
any updates on this ? facing the same issue it fails alternately if file exists. Edit: Thanks @FaKenKoala for your answer, it really helped me ❤. But I think these cases should be handled by plugin. |
It happens when the task status for the file in the Downloader DB is not 'complete,' but you have a fully downloaded file in the local directory. The problem is that the plugin sees the fully downloaded file as a partially downloaded one. If the same file exists, the plugin resumes downloading and sends the size of the byes to the server, which causes HTTP status 416 Range Not Satisfiable. We could reduce the size of downloadedBytes by a small amount and resume downloading in the setupPartialDownloadedDataHeader method. |
Same problem form me |
@Faaatman Would be great to see your PR fixing this :) |
This is worked on in #708 :) |
you all have this open failed: EACCES (Permission denied) error? I'm not sure that I have the same issue as you but it seems like that |
should add this
The text was updated successfully, but these errors were encountered: