Skip to content
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

Numbered Suffix For Existing Filenames w/ Overwrite Files Off #530

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NickvisionTubeConverter.GNOME/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Program(string[] args)
@"* Added the option to prevent suspend while using Parabolic
* Improved bitrate used for audio-only downloads with the best quality
* Parabolic will now prefer videos with the h264 codec when downloading in the mp4 format. If space is a concern, users are recommended to download in the webm format which uses the vp* codec
* If overwriting files is off and a download's file name exists, a numbered suffix will be attached to the end of the file name to prevent error
* Fixed an issue where downloads with specific timeframes would download incorrectly
* Fixed an issue where Parabolic would be unusable on systems without NetworkManager installed
* Fixed an issue where Parabolic would say no active internet connection even though there was a connection established
Expand Down
7 changes: 7 additions & 0 deletions NickvisionTubeConverter.Shared/Models/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ public void Start(DownloadOptions options)
genericExtensionFound = true;
}
}
var baseFilename = Filename;
var i = 0;
while (!options.OverwriteExistingFiles && File.Exists(path.Replace(Id.ToString(), Path.GetFileNameWithoutExtension(Filename))))
{
i++;
Filename = $"{Path.GetFileNameWithoutExtension(baseFilename)} ({i}){Path.GetExtension(baseFilename)}";
}
try
{
File.Move(path, path.Replace(Id.ToString(), Path.GetFileNameWithoutExtension(Filename)), options.OverwriteExistingFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<p>- Added the option to prevent suspend while using Parabolic</p>
<p>- Improved bitrate used for audio-only downloads with the best quality</p>
<p>- Parabolic will now prefer videos with the h264 codec when downloading in the mp4 format. If space is a concern, users are recommended to download in the webm format which uses the vp* codec</p>
<p>- If overwriting files is off and a download's file name exists, a numbered suffix will be attached to the end of the file name to prevent error</p>
<p>- Fixed an issue where downloads with specific timeframes would download incorrectly</p>
<p>- Fixed an issue where Parabolic would be unusable on systems without NetworkManager installed</p>
<p>- Fixed an issue where Parabolic would say no active internet connection even though there was a connection established</p>
Expand Down