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

Replace os.path in storage module #30

Merged
merged 2 commits into from
Jan 4, 2020
Merged

Replace os.path in storage module #30

merged 2 commits into from
Jan 4, 2020

Conversation

jodal
Copy link
Member

@jodal jodal commented Jan 3, 2020

PR #29 replaced all the os.path usage in the scanner. This finishes the work by replacing all os.path usage in the storage module, and thus fixes #20.

@jodal jodal added this to the v3.1.0 milestone Jan 3, 2020
@jodal jodal requested review from adamcik, kingosticks and tkem January 3, 2020 20:05
@jodal jodal self-assigned this Jan 3, 2020
@jodal jodal changed the title Replace os.path Replace os.path in storage module Jan 3, 2020
@codecov
Copy link

codecov bot commented Jan 3, 2020

Codecov Report

Merging #30 into master will increase coverage by 0.07%.
The diff coverage is 26.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   51.04%   51.12%   +0.07%     
==========================================
  Files           9        9              
  Lines         764      757       -7     
==========================================
- Hits          390      387       -3     
+ Misses        374      370       -4
Impacted Files Coverage Δ
mopidy_local/schema.py 76.28% <0%> (ø) ⬆️
mopidy_local/library.py 39.41% <0%> (ø) ⬆️
mopidy_local/storage.py 44.63% <29.16%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f5872c...b4a25a7. Read the comment docs.

except Exception as e:
shutil.rmtree(self._image_dir)
self._image_dir.mkdir()
except IOError as e:
logger.warning("Error clearing image directory: %s", e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-strings while we are here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's lots of modulo formatting in this file, so I opted to not change anything more than the lines I changed anyway.

path = os.path.join(root, name)
logger.info("Deleting file %s", path)
os.remove(path)
for image_path in self._image_dir.glob("**/*"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note Using the “**” pattern in large directory trees may consume an inordinate amount of time.

Should we be using glob.iglob or are we going to have this problem anyway. Same would go for any other uses of glob.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that note mostly refers to "if you run this on something unknown, you don't know how long it will take". We only use it on dirs we've built ourselves. The size of this directory tree isn't any larger than the number of albums in your local music collection.

@jodal jodal merged commit 6865fac into mopidy:master Jan 4, 2020
@jodal jodal deleted the replace-os.path branch January 4, 2020 17:51
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

Successfully merging this pull request may close these issues.

Convert to pathlib
3 participants