[GH-ISSUE #30] File comparison failure #665

Closed
opened 2026-03-01 17:29:01 +03:00 by kerem · 1 comment
Owner

Originally created by @AvxGadzx on GitHub (Jul 21, 2025).
Original GitHub issue: https://github.com/afkarxyz/SpotiFLAC/issues/30

Problem

Some songs get randomly deleted even though the terminal output seems ok.
Sideinfo: Version 3.9 (newest). Source: Tidal.

Terminal output (two songs, same output)

Fetching: You_name_it
Found: You_name_it
Fetching URL...
URL found
Downloading to: /someplace/You_name_it
50% - 1.0 MB/s
100% - 1.0 MB/s
Download complete
Adding metadata...
Embedding metadata...
Album art embedded
Metadata embedded successfully for: You_name_it
Metadata saved
Done

Application output (Two different application outputs. One song will be deleted)

Starting download (1/2): You_name_it
Searching and downloading from Tidal for ISRC: You_name_it
Download progress: 100.00% (2.0MB/2.0MB)
File already exists: You_name_it
Skipped: You_name_it

Starting download (2/2): You_name_it_2
Searching and downloading from Tidal for ISRC: You_name_it_2
Download progress: 100.00% (2.0MB/2.0MB)
Failed to download: You_name_it_2
Error: [Errno 2] No such file or directory: '/somewhere/You_name_it_2' -> '/somewhere/You_name_it_2'

Problem source

I think the problem is in line 232 - 242 of the SpotiFLAC.py

if downloaded_file == new_filepath: 
    self.progress.emit(f"File already exists: {new_filename}", 0)
    self.progress.emit(f"Skipped: {track.title} - {track.artists}", 
                int((i + 1) / total_tracks * 100))
    continue

if os.path.exists(downloaded_file) and downloaded_file != new_filepath:
    if os.path.exists(new_filepath):
        os.remove(new_filepath)
    os.rename(downloaded_file, new_filepath)
    self.progress.emit(f"File renamed to: {new_filename}", 0)

When i comment out the ..

    if os.path.exists(new_filepath):
        os.remove(new_filepath)

.. the song won't be deleted and I don't get an [Errno 2] exeption.

PS:
The if downloaded_file == new_filepath: doesn't work too. There is no skipping at this point.

Easy fix (i didn't debug the down/new_file comparison. Maybe it can be removed)

No missing file, no problemo.

if downloaded_file == new_filepath: 
    continue

if os.path.exists(downloaded_file) and downloaded_file != new_filepath:
    os.rename(downloaded_file, new_filepath)
    self.progress.emit(f"File renamed to: {new_filename}", 0)

I hope this helps

Originally created by @AvxGadzx on GitHub (Jul 21, 2025). Original GitHub issue: https://github.com/afkarxyz/SpotiFLAC/issues/30 ### Problem Some songs get randomly deleted even though the terminal output seems ok. *Sideinfo: Version 3.9 (newest). Source: Tidal.* ### Terminal output (two songs, same output) ``` Fetching: You_name_it Found: You_name_it Fetching URL... URL found Downloading to: /someplace/You_name_it 50% - 1.0 MB/s 100% - 1.0 MB/s Download complete Adding metadata... Embedding metadata... Album art embedded Metadata embedded successfully for: You_name_it Metadata saved Done ``` ### Application output (Two different application outputs. One song will be deleted) ``` Starting download (1/2): You_name_it Searching and downloading from Tidal for ISRC: You_name_it Download progress: 100.00% (2.0MB/2.0MB) File already exists: You_name_it Skipped: You_name_it Starting download (2/2): You_name_it_2 Searching and downloading from Tidal for ISRC: You_name_it_2 Download progress: 100.00% (2.0MB/2.0MB) Failed to download: You_name_it_2 Error: [Errno 2] No such file or directory: '/somewhere/You_name_it_2' -> '/somewhere/You_name_it_2' ``` ### Problem source I think the problem is in line 232 - 242 of the SpotiFLAC.py ```python if downloaded_file == new_filepath: self.progress.emit(f"File already exists: {new_filename}", 0) self.progress.emit(f"Skipped: {track.title} - {track.artists}", int((i + 1) / total_tracks * 100)) continue if os.path.exists(downloaded_file) and downloaded_file != new_filepath: if os.path.exists(new_filepath): os.remove(new_filepath) os.rename(downloaded_file, new_filepath) self.progress.emit(f"File renamed to: {new_filename}", 0) ``` When i comment out the .. ```python if os.path.exists(new_filepath): os.remove(new_filepath) ``` .. the song won't be deleted and I don't get an [Errno 2] exeption. PS: The `if downloaded_file == new_filepath:` doesn't work too. There is no skipping at this point. ### Easy fix (i didn't debug the down/new_file comparison. Maybe it can be removed) No missing file, no problemo. ```python if downloaded_file == new_filepath: continue if os.path.exists(downloaded_file) and downloaded_file != new_filepath: os.rename(downloaded_file, new_filepath) self.progress.emit(f"File renamed to: {new_filename}", 0) ``` I hope this helps
kerem closed this issue 2026-03-01 17:29:01 +03:00
Author
Owner

@afkarxyz commented on GitHub (Jul 22, 2025):

Thank you, I have implemented it in v4.0

<!-- gh-comment-id:3100194438 --> @afkarxyz commented on GitHub (Jul 22, 2025): Thank you, I have implemented it in v4.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SpotiFLAC#665
No description provided.