ipfs: Crash when adding to library
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
### Problem
Running this command in verbose (`-vv`) mode:
```sh
$ beet -vv ipfs -g QmWZLpxqkcH6wwD1ZnpbhpSy6jhGZub42Vv24sh9rNPXFi
```
Led to this problem:
```
user configuration: /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths:
Sending event: pluginload
library database: /home/user/media/music/musiclibrary.blb
library directory: /home/user/media/music
Sending event: library_opened
ipfs: Getting QmWZLpxqkcH6wwD1ZnpbhpSy6jhGZub42Vv24sh9rNPXFi from ipfs
Sending event: import_begin
No files imported from /home/user/src/beets/QmWZLpxqkcH6wwD1ZnpbhpSy6jhGZub42Vv24sh9rNPXFi
Traceback (most recent call last):
File "/home/user/.local/bin/beet", line 11, in
sys.exit(main())
File "/home/user/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1209, in main
_raw_main(args)
File "/home/user/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1196, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/user/.local/lib/python2.7/site-packages/beetsplug/ipfs.py", line 73, in func
self.ipfs_get(lib, ui.decargs(args))
File "/home/user/.local/lib/python2.7/site-packages/beetsplug/ipfs.py", line 151, in ipfs_get
self.ipfs_get_from_hash(lib, query)
File "/home/user/.local/lib/python2.7/site-packages/beetsplug/ipfs.py", line 171, in ipfs_get_from_hash
shutil.rmtree(_hash)
File "/usr/lib/python2.7/shutil.py", line 239, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "/usr/lib/python2.7/shutil.py", line 237, in rmtree
names = os.listdir(path)
OSError: [Errno 20] Not a directory: 'QmWZLpxqkcH6wwD1ZnpbhpSy6jhGZub42Vv24sh9rNPXFi'
```
### Setup
I tried a few combinations:
* OS: Linux
* Python version: 2.7.12
* beets version: v1.4.3
* Turning off plugins made problem go away (yes/no): no
&
* OS: Linux
* Python version: 2.7.12
* beets version: ca8c557
* Turning off plugins made problem go away (yes/no): no
&
* OS: Linux
* Python version: 3.5.2
* beets version: ca8c557
* Turning off plugins made problem go away (yes/no): no
My configuration (output of `beet config`) is:
```yaml
paths:
default: $albumartist/$album%aunique{}/$track $title
singleton: Non-Album/$artist/$title
comp: Compilations/$album%aunique{}/$track $title
albumtype:soundtrack: Soundtracks/$album/$track $title
asciify_paths: yes
fetchart:
store_source: yes
auto: yes
minwidth: 0
sources:
- filesystem
- coverart
- itunes
- amazon
- albumart
google_engine: 001442825323518660753:hrh5ch1gjzm
enforce_ratio: no
cautious: no
maxwidth: 0
google_key: REDACTED
fanarttv_key: REDACTED
cover_names:
- cover
- front
- art
- album
- folder
library: ~/media/music/musiclibrary.blb
replace:
'[\\/]': _
^\.: _
'[\x00-\x1f]': _
'[<>:"\?\*\|]': _
\.$: _
\s+$: ''
^\s+: ''
\s: '-'
plugins: 'fromfilename fetchart mbsync ipfs
'
directory: ~/media/music
import:
move: yes
write: yes
languages: en
log: ~/media/music/beets-log.txt
match:
preferred:
media: [CD]
ipfs:
auto: yes
```
Contributor guide
Research direction
Start in beetsplug/ipfs.py at the ipfs_get_from_hash path shown in the traceback, especially around line 171, and reproduce the command with the provided hash. Trace how the fetched path is handled after no files are imported; done means the command no longer crashes with OSError when that path is not a directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100