beetbox / beetbox/beets

permission plugin should run before most other plugins (especially scrub)

Open
#1,823 3 comments 0 reactions 0 assignees View on GitHub
feature scrub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

``` sh
$ beet import Tricot\ -\ Pork\ Ginger\ V0/
/home/johnny/temp/Tricot - Pork Ginger V0 (1 items)

Tagging:
tricot - ポークジンジャー - Pork Ginger
URL:
https://www.discogs.com/tricot-%E3%83%9D%E3%83%BC%E3%82%AF%E3%82%B8%E3%83%B3%E3%82%B8%E3%83%A3%E3%83%BC-Pork-Ginger/release/7886145
(Similarity: 77.8%) (source, year, country, media) (Discogs, File, 2015, Japan, Bakuretsu Records)
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? A
error writing /home/media/music/tricot/ポークジンジャー - Pork Ginger/01 - ポークジンジャー - Pork Ginger.mp3: [Errno 13] Permission denied: '/home/media/music/tricot/\xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger/01 - \xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger.mp3'
scrub: could not scrub /home/media/music/tricot/ポークジンジャー - Pork Ginger/01 - ポークジンジャー - Pork Ginger.mp3: [Errno 13] Permission denied: '/home/media/music/tricot/\xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger/01 - \xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger.mp3'
scrub: could not scrub /home/media/music/tricot/ポークジンジャー - Pork Ginger/01 - ポークジンジャー - Pork Ginger.mp3: [Errno 13] Permission denied: '/home/media/music/tricot/\xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger/01 - \xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger.mp3'
error writing /home/media/music/tricot/ポークジンジャー - Pork Ginger/01 - ポークジンジャー - Pork Ginger.mp3: [Errno 13] Permission denied: '/home/media/music/tricot/\xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger/01 - \xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger.mp3'
Traceback (most recent call last):
File "/home/johnny/src/beets/beet", line 21, in
beets.ui.main()
File "/home/johnny/src/beets/beets/ui/__init__.py", line 1207, in main
_raw_main(args)
File "/home/johnny/src/beets/beets/ui/__init__.py", line 1197, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/johnny/src/beets/beets/ui/commands.py", line 947, in import_func
import_files(lib, paths, query)
File "/home/johnny/src/beets/beets/ui/commands.py", line 924, in import_files
session.run()
File "/home/johnny/src/beets/beets/importer.py", line 318, in run
pl.run_parallel(QUEUE_SIZE)
File "/home/johnny/src/beets/beets/util/pipeline.py", line 348, in run
self.coro.send(msg)
File "/home/johnny/src/beets/beets/util/pipeline.py", line 161, in coro
task = func(*(args + (task,)))
File "/home/johnny/src/beets/beets/importer.py", line 1381, in manipulate_files
session=session,
File "/home/johnny/src/beets/beets/importer.py", line 679, in manipulate_files
plugins.send('import_task_files', session=session, task=self)
File "/home/johnny/src/beets/beets/plugins.py", line 459, in send
result = handler(**arguments)
File "/home/johnny/src/beets/beets/plugins.py", line 124, in wrapper
return func(*args, **kwargs)
File "/home/johnny/src/beets/beetsplug/scrub.py", line 145, in import_task_files
self._scrub_item(item)
File "/home/johnny/src/beets/beetsplug/scrub.py", line 138, in _scrub_item
mf.save()
File "/home/johnny/src/beets/beets/mediafile.py", line 1434, in save
self.mgfile.save(**kwargs)
File "/usr/lib/python2.7/site-packages/mutagen/_file.py", line 112, in save
return self.tags.save(filename, **kwargs)
File "/usr/lib/python2.7/site-packages/mutagen/id3/__init__.py", line 529, in save
f = open(filename, 'rb+')
IOError: [Errno 13] Permission denied: '/home/media/music/tricot/\xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger/01 - \xe3\x83\x9d\xe3\x83\xbc\xe3\x82\xaf\xe3\x82\xb8\xe3\x83\xb3\xe3\x82\xb8\xe3\x83\xa3\xe3\x83\xbc - Pork Ginger.mp3'
```

It turns out the file was 444, so it couldn't scrub it.

Contributor guide

Open the contributing guide

Research direction

Trace the import flow in beets/importer.py and plugin dispatch in beets/plugins.py, then inspect the scrub handler in beets/beetsplug/scrub.py. Reproduce the read-only-file import shown in the report and determine how plugin ordering affects it. Done means the permission plugin runs before scrub during import, especially for files that cannot be written.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.