CC-2977: Never delete files from the database
- Files are marked deleted(file_exists to false) on deletion. - Dirs are marked removed(removed flag to true) on removal of watched folder in a usual way. If dir is unmounted, without being removed from watched list first, it will be marked as not exists(exist flag to false) - Manage Media Folders will show if dirs exist or not( mounted or not) - Playlist builder will show if files exists or not
This commit is contained in:
parent
61c5355e8a
commit
04b48d47cc
16 changed files with 374 additions and 69 deletions
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
import time
|
||||
import pyinotify
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
from api_clients import api_client
|
||||
|
||||
class AirtimeMediaMonitorBootstrap():
|
||||
|
||||
|
||||
"""AirtimeMediaMonitorBootstrap constructor
|
||||
|
||||
Keyword Arguments:
|
||||
|
@ -13,11 +14,16 @@ class AirtimeMediaMonitorBootstrap():
|
|||
pe -- reference to an instance of ProcessEvent
|
||||
api_clients -- reference of api_clients to communicate with airtime-server
|
||||
"""
|
||||
def __init__(self, logger, pe, api_client, mmc):
|
||||
def __init__(self, logger, pe, api_client, mmc, wm):
|
||||
self.logger = logger
|
||||
self.pe = pe
|
||||
self.api_client = api_client
|
||||
self.mmc = mmc
|
||||
self.wm = wm
|
||||
# add /etc on watch list so we can detect mount
|
||||
self.mount_file = "/etc"
|
||||
self.logger.info("Adding %s on watch list...", self.mount_file)
|
||||
self.wm.add_watch(self.mount_file, pyinotify.ALL_EVENTS, rec=False, auto_add=False)
|
||||
|
||||
"""On bootup we want to scan all directories and look for files that
|
||||
weren't there or files that changed before media-monitor process
|
||||
|
@ -79,6 +85,10 @@ class AirtimeMediaMonitorBootstrap():
|
|||
if len(file_path.strip(" \n")) > 0:
|
||||
all_files_set.add(file_path[len(dir):])
|
||||
|
||||
# if dir doesn't exists, update db
|
||||
if not os.path.exists(dir):
|
||||
self.pe.handle_watched_dir_missing(dir)
|
||||
|
||||
if os.path.exists(self.mmc.timestamp_file):
|
||||
"""find files that have been modified since the last time media-monitor process started."""
|
||||
time_diff_sec = time.time() - os.path.getmtime(self.mmc.timestamp_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue