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

Fetchart Error: The process cannot access the file because it is being used by another process while moving #5521

Open
robuck86 opened this issue Nov 26, 2024 · 8 comments

Comments

@robuck86
Copy link

robuck86 commented Nov 26, 2024

Why do I keep getting this error when using fetchart? When I use fetchart to find a cover (manually or on import) it seems to download and move ONE cover.jpg to the correct spot, crash and not delete the tmp files nor does it continue the queue. I've tried clearing the tmp folder, rebooting. Thought it works, I can only 'fetchart' one album at a time.

``Error: The process cannot access the file because it is being used by another process while moving C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\xvbmqvlo.jpg to T:\navidrome\music\beets\XMAS\The Canadian Brass\Christmas With The Canadian Brass\cover.1.jpg` 

fetchart: The Coasters - Christmas With the Coasters: found album art
Error: The process cannot access the file because it is being used by another process while moving C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\gkj0rosm.jpg to T:\navidrome\music\beets\XMAS\Nat King Cole\The Magic of Christmas\cover.jpg
PS C:\beets> beet fetchart -q
fetchart: Nat King Cole - The Magic of Christmas: found album art
Error: The process cannot access the file because it is being used by another process while moving C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\_detmij9.jpg to T:\navidrome\music\beets\XMAS\Judy Collins\Christmas With Judy Collins\cover.jpg
PS C:\beets> beet fetchart -q
fetchart: Judy Collins - Christmas With Judy Collins: found album art

`

  • OS: Windows 11
  • Python version: 3.13
  • beets version: 2.1.0
  • Turning off plugins made problem go away (yes/no): yes

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    import.write: no
    auto: yes
    bing_client_secret: REDACTED
    bing_lang_to:
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    fallback:
    force: no
    local: no
    synced: no
    sources:
    - google
    - genius
    - tekstowo
    - lrclib
    dist_thresh: 0.1
directory: T:/navidrome/music/beets
# --------------- Main ---------------

library: T:/navidrome/Test/musiclibrary.db

# --------------- Plugins ---------------

plugins: fetchart embedart discogs lastgenre lyrics mbsync smartplaylist spotify convert
paths:
    default: $albumartist/$album/$track $title
    singleton: Singletons/$artist - $title
    xmas:XMAS: XMAS/$albumartist/$album/$title
    comp: Compilation/$album/$track $title
    albumtype:soundtrack: Soundtracks/$album/$track $title
convert:
    auto: no
    dest: T:/converted/
    pretend: no
    link: no
    hardlink: no
    threads: 16
    format: mp3
    id3v23: inherit
    formats:
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    max_bitrate:
    auto_keep: no
    tmpdir:
    quiet: no
    embed: yes
    paths: {}
    no_convert: ''
    never_convert_lossy_files: no
    copy_album_art: no
    album_art_maxwidth: 0
    delete_originals: no
    playlist:
spotify:
    source_weight: 0.7
    mode: open
    region_filter: US
    show_failures: yes
    tiebreak: first
    regex: [{field: albumartist, search: Something, replace: Replaced}, {field: title, search: Something Else, replace: AlsoReplaced}]
    artist_field: albumartist
    album_field: album
    track_field: title
    client_id: 4e414367a1d14c75a5c5129a627fcab8
    client_secret: REDACTED
    tokenfile: spotify_token.json
lastgenre:
    count: 4
    separator: '; '
    whitelist: whitelist.txt
    source: track
    min_weight: 10
    fallback:
    canonical: no
    force: yes
    auto: yes
    prefer_specific: no
    title_case: yes

# --------------- Import ---------------

clutter:
- '*.jpg'
- '*.jpeg'
- '*.txt'
- '*.log'

match:
    preferred:
        countries: [US, GB|UK]
        media: [CD, Digital Media|File]
        original_year: yes

smartplaylist:
    relative_to: T:/navidrome/music/beets
    playlist_dir: T:/navidrome/music/beets
    forward_slash: no
    playlists: [{name: Xmas.m3u, query: 'xmas:XMAS'}]
    auto: yes
    uri_format:
    fields: []
    prefix: REDACTED
    urlencode: no
    pretend_paths: no
    output: m3u
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    - cover_art_url
    store_source: no
    high_resolution: no
    deinterlace: no
    cover_format:
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    lastfm_key: REDACTED
discogs:
    apikey: REDACTED
    apisecret: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    user_token: REDACTED
    separator: ', '
    index_tracks: no
    append_style_genre: no
@robuck86
Copy link
Author

robuck86 commented Nov 28, 2024

I don't know if it's helpful, but I'll share a more verbose log of a fetchart -q command. It's a reproduceable error with every attempt. I can delete the tmp jpgs in windows explorer immediately after it crashes, so I think fetchart must be the one 'using' it?

`fetchart: trying source filesystem for album The Chieftains - The Bells of Dublin
fetchart: trying source coverart for album The Chieftains - The Bells of Dublin
fetchart: getting URL: https://coverartarchive.org/release/aa8ba721-3f7b-4b03-afaa-c63acb2d9202
fetchart: downloading image: http://coverartarchive.org/release/aa8ba721-3f7b-4b03-afaa-c63acb2d9202/13719332555.jpg
fetchart: downloaded art to: C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\m4vapawn.jpg
fetchart: using remote image C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\m4vapawn.jpg
Traceback (most recent call last):
  File "C:\Users\rob86\AppData\Local\Programs\Python\Python313\Lib\site-packages\beets\util\__init__.py", line 529, in move
    os.replace(syspath(path), syspath(dest))
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\?\\C:\\Users\\rob86\\AppData\\Local\\Temp\\beets\\beetsplug_fetchart\\m4vapawn.jpg' -> '\\\\?\\G:\\navidrome\\music\\beets\\christmas\\The Chieftains\\The Bells of Dublin\\cover.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rob86\AppData\Local\Programs\Python\Python313\Lib\site-packages\beets\util\__init__.py", line 556, in move
    os.remove(syspath(path))
    ~~~~~~~~~^^^^^^^^^^^^^^^
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\?\\C:\\Users\\rob86\\AppData\\Local\\Temp\\beets\\beetsplug_fetchart\\m4vapawn.jpg'

Error: The process cannot access the file because it is being used by another process while moving C:\Users\rob86\AppData\Local\Temp\beets\beetsplug_fetchart\m4vapawn.jpg to G:\navidrome\music\beets\christmas\The Chieftains\The Bells of Dublin\cover.jpg`

@arogl
Copy link
Contributor

arogl commented Nov 28, 2024

I suspect it might we windows defender.

But the confusing thing is the cover already exists in the destination folder.

It is not easily repeatable either 😞 so lots of debug prints may not find it in an import.

@robuck86
Copy link
Author

I tried disabling Defender's Real-time Protection but it didn't help. I agree the logs don't seem to show much. I've tried rebooting and running with admin. It's a strange problem!

It definitely does download and move a cover.jpg, if only it wasn't crashing after it does it. I tried sacad_r (https://github.com/desbma/sacad) to do a batch and it works, but I'd prefer to do it through beets when I import multiple albums. 😩

@Leitmotif7
Copy link

Have the exact same issue, on Windows.

@robuck86
Copy link
Author

Have the exact same issue, on Windows.

It's reassuring to hear it's not just me. It's a shame, because I prefer using beets more than MusicBrainz Picard, but I've had to give up on beets and use Picard because of this issue.

@seth-milojevic
Copy link

I was able to get around this issue on windows by doing the following (confirming that it is caused by windows defender):
This is all on windows 11

  1. Open Virus & threat protection
  2. Under "Virus & threat protection settings", click "Manage settings"
  3. Scroll down to "Exclusions" and click "Add or remove exclusions"
  4. Click "Add an exclusion" and choose "Folder" from the drop down
  5. Enter C:\Users\your_user\AppData\Local\Temp\beets replacing your_user with your windows user and the drive letter if necessary
    Note: if the beets directory doesn't exist, you'll have to run beets or make it yourself

It looks like windows defender is trying to access / scan the file at the same time that beets is using it causing the issue, I used process monitor to discover this.

@robuck86
Copy link
Author

Wow! It really worked. I tried a 6 album batch and it fetched the art perfectly. I'd tried disabling real-time protection, but I didn't think to try adding an exclusion. Thanks so much!

The temp jpgs aren't being deleted (should they be?) after the processing, but at least it works.

@seth-milojevic
Copy link

I think they should be deleted, but mine are also not being deleted. I'll just have to keep an eye on the folder to make sure it doesn't fill up my drive for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants