REMOVE_UNUSED_FILES option
This commit is contained in:
parent
b0c2d2195e
commit
255d97d42f
3 changed files with 19 additions and 5 deletions
|
@ -68,7 +68,7 @@ MPD_PORT
|
|||
If you are not using a socket, but a TCP address (which is *not* suggested), this is how you can specify the
|
||||
port.
|
||||
DEBUG
|
||||
you can set it to ``true`` or ``false``. Defaults to ``false``.
|
||||
you can set it to ``true`` or ``false``. Defaults to ``false``. Will enable extremely verbose output.
|
||||
TMPDIR
|
||||
The base for larigira tmpdir. Please note that larigira will create its own directory inside this
|
||||
temporary directory. This defaults to the system-wide ``$TMPDIR``, or to ``/tmp/`` if not ``TMPDIR`` is
|
||||
|
@ -154,3 +154,9 @@ LARIGIRA_UI_CALENDAR_DATE_FMT
|
|||
The format to show in ``/db/calendar`` page. The format is specified `here <http://babel.pocoo.org/en/latest/dates.html>`_. Default is ``medium``.
|
||||
|
||||
As an example, ``eee dd LLL`` will show ``Sun 10 Mar`` for english, and ``dom 10 mar`` for italian.
|
||||
|
||||
Debug and development
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
REMOVE_UNUSED_FILES
|
||||
By default, larigira removes the file it generates, as soon as they are no longer in MPD playlist. There is no good reason to change this behavior, unless you need to debug what's going on. For example, if you want to inspect files. Set this to `false` keep everything.
|
||||
|
|
|
@ -30,6 +30,9 @@ def get_conf(prefix="LARIGIRA_"):
|
|||
conf["CHECK_SECS"] = 20 # period for checking playlist length
|
||||
conf["EVENT_TICK_SECS"] = 30 # period for scheduling events
|
||||
conf["DEBUG"] = False
|
||||
conf[
|
||||
"REMOVE_UNUSED_FILES"
|
||||
] = True # please keep it to True unless you are into deep debugging!
|
||||
conf["LOG_CONFIG"] = False
|
||||
conf["TMPDIR"] = os.getenv("TMPDIR", "/tmp/")
|
||||
conf["FILE_PATH_SUGGESTION"] = () # tuple of paths
|
||||
|
@ -71,7 +74,9 @@ def from_envvars(prefix=None, envvars=None, as_json=True):
|
|||
|
||||
if not envvars:
|
||||
envvars = {
|
||||
k: k[len(prefix) :] for k in os.environ.keys() if k.startswith(prefix)
|
||||
k: k[len(prefix) :]
|
||||
for k in os.environ.keys()
|
||||
if k.startswith(prefix)
|
||||
}
|
||||
|
||||
for env_name, name in envvars.items():
|
||||
|
|
|
@ -4,9 +4,10 @@ This component will look for files to be removed. There are some assumptions:
|
|||
own specific TMPDIR
|
||||
* MPD URIs are parsed, and only file:/// is supported
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
from os.path import normpath
|
||||
import logging
|
||||
|
||||
import mpd
|
||||
|
||||
|
||||
|
@ -64,11 +65,13 @@ class UnusedCleaner:
|
|||
"""check playlist + internal watchlist to see what can be removed"""
|
||||
mpdc = self._get_mpd()
|
||||
files_in_playlist = {
|
||||
song["file"] for song in mpdc.playlistid() if song["file"].startswith("/")
|
||||
song["file"]
|
||||
for song in mpdc.playlistid()
|
||||
if song["file"].startswith("/")
|
||||
}
|
||||
for fpath in self.waiting_removal_files - files_in_playlist:
|
||||
# we can remove it!
|
||||
self.log.debug("removing unused: %s", fpath)
|
||||
self.waiting_removal_files.remove(fpath)
|
||||
if os.path.exists(fpath):
|
||||
if os.path.exists(fpath) and self.conf["REMOVE_UNUSED_FILES"]:
|
||||
os.unlink(fpath)
|
||||
|
|
Loading…
Reference in a new issue