diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index bb5246aad..9028fe5aa 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -824,12 +824,16 @@ class StoredFile { public static function listAllFiles($dir_id){ global $CC_DBC; - $sql = "SELECT m.directory || '/' || f.filepath as fp" - ." FROM CC_MUSIC_DIRS m" - ." LEFT JOIN CC_FILES f" - ." ON m.id = f.directory" - ." WHERE m.id = f.directory" - ." AND m.id = $dir_id"; + // $sql = "SELECT m.directory || '/' || f.filepath as fp" + // ." FROM CC_MUSIC_DIRS m" + // ." LEFT JOIN CC_FILES f" + // ." ON m.id = f.directory" + // ." WHERE m.id = f.directory" + // ." AND m.id = $dir_id"; + $sql = "SELECT filepath as fp" + ." FROM CC_FILES" + ." WHERE f.directory = $dir_id"; + $rows = $CC_DBC->getAll($sql); $results = array(); diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index aa7a6e3d9..428b44ab9 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -407,6 +407,10 @@ class AirTimeApiClient(ApiClientInterface): return response + #returns a list of all db files for a given directory in JSON format: + #{"files":["path/to/file1", "path/to/file2"]} + #Note that these are relative paths to the given directory. The full + #path is not returned. def list_all_db_files(self, dir_id): logger = logging.getLogger() try: diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py index 730da8d6d..e4f87f18b 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py @@ -55,7 +55,7 @@ class AirtimeMediaMonitorBootstrap(): all_files_set = set() for file_path in new_files: if len(file_path.strip(" \n")) > 0: - all_files_set.add(file_path) + all_files_set.add(file_path[len(dir)+1:]) if os.path.exists("/var/tmp/airtime/.media_monitor_boot"): @@ -73,7 +73,7 @@ class AirtimeMediaMonitorBootstrap(): for file_path in new_files: if len(file_path.strip(" \n")) > 0: - new_and_modified_files.add(file_path) + new_and_modified_files.add(file_path[len(dir)+1:]) #new_and_modified_files gives us a set of files that were either copied or modified #since the last time media-monitor was running. These files were collected based on @@ -94,14 +94,16 @@ class AirtimeMediaMonitorBootstrap(): open("/var/tmp/airtime/.media_monitor_boot","w") for file_path in deleted_files_set: - self.pe.handle_removed_file(False, file_path) + self.pe.handle_removed_file(False, "%s/%s" % (dir, file_path)) for file_path in new_files_set: if os.path.exists(file_path): + file_path = "%s/%s" % (dir, file_path) self.pe.handle_created_file(False, os.path.basename(file_path), file_path) for file_path in modified_files_set: if os.path.exists(file_path): + file_path = "%s/%s" % (dir, file_path) self.pe.handle_modified_file(False, os.path.basename(file_path), file_path) def execCommand(self, command):