CC-2882: Airtime cannot delete watched folder when is been renamed
- done
This commit is contained in:
parent
b1fa8901ca
commit
d1542b0d89
3 changed files with 25 additions and 33 deletions
|
@ -542,6 +542,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
$file->delete();
|
$file->delete();
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
$this->view->id = $file->getId();
|
$this->view->id = $file->getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,10 +284,6 @@ class Application_Model_MusicDir {
|
||||||
$real_path = realpath($p_dir)."/";
|
$real_path = realpath($p_dir)."/";
|
||||||
if($real_path != "/"){
|
if($real_path != "/"){
|
||||||
$p_dir = $real_path;
|
$p_dir = $real_path;
|
||||||
}else{
|
|
||||||
// this is the case where user removes watched directory on
|
|
||||||
// the file system directly.
|
|
||||||
$p_dir .= "/";
|
|
||||||
}
|
}
|
||||||
$dir = Application_Model_MusicDir::getDirByPath($p_dir);
|
$dir = Application_Model_MusicDir::getDirByPath($p_dir);
|
||||||
if($dir == NULL){
|
if($dir == NULL){
|
||||||
|
|
|
@ -42,44 +42,41 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
|
|
||||||
def process_IN_MOVE_SELF(self, event):
|
def process_IN_MOVE_SELF(self, event):
|
||||||
self.logger.info("event: %s", event)
|
self.logger.info("event: %s", event)
|
||||||
|
path = event.path
|
||||||
if event.dir:
|
if event.dir:
|
||||||
path = event.path
|
|
||||||
wd = self.wm.get_wd(path)
|
|
||||||
self.logger.info("Removing watch on: %s wd %s", path, wd)
|
|
||||||
self.wm.rm_watch(wd, rec=True)
|
|
||||||
if "-unknown-path" in path:
|
if "-unknown-path" in path:
|
||||||
|
unkown_path = path
|
||||||
pos = path.find("-unknown-path")
|
pos = path.find("-unknown-path")
|
||||||
path = path[0:pos]
|
path = path[0:pos]+"/"
|
||||||
|
|
||||||
list = self.api_client.list_all_watched_dirs()
|
list = self.api_client.list_all_watched_dirs()
|
||||||
# case where the dir that is being watched is moved to somewhere
|
# case where the dir that is being watched is moved to somewhere
|
||||||
if path in list:
|
if path in list[u'dirs'].values():
|
||||||
self.logger.info("Requesting the airtime server to remove '%s'", path)
|
self.logger.info("Requesting the airtime server to remove '%s'", path)
|
||||||
res = self.api_client.remove_watched_dir(path)
|
res = self.api_client.remove_watched_dir(path)
|
||||||
if(res is None):
|
if(res is None):
|
||||||
self.logger.info("Unable to connect to the Airtime server.")
|
self.logger.info("Unable to connect to the Airtime server.")
|
||||||
# sucess
|
# sucess
|
||||||
if(res['msg']['code'] == 0):
|
if(res['msg']['code'] == 0):
|
||||||
self.logger.info("%s removed from watch folder list successfully.", path)
|
self.logger.info("%s removed from watch folder list successfully.", path)
|
||||||
|
else:
|
||||||
|
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
|
||||||
else:
|
else:
|
||||||
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
|
# subdir being moved
|
||||||
else:
|
# in this case, it has to remove watch manualy and also have to manually delete all records
|
||||||
self.file_events.append({'mode': self.config.MODE_DELETE_DIR, 'filepath': path})
|
# on cc_files table
|
||||||
|
wd = self.wm.get_wd(unkown_path)
|
||||||
|
self.logger.info("Removing watch on: %s wd %s", unkown_path, wd)
|
||||||
|
self.wm.rm_watch(wd, rec=True)
|
||||||
|
self.file_events.append({'mode': self.config.MODE_DELETE_DIR, 'filepath': path})
|
||||||
|
|
||||||
|
|
||||||
def process_IN_DELETE_SELF(self, event):
|
def process_IN_DELETE_SELF(self, event):
|
||||||
self.logger.info("event: %s", event)
|
self.logger.info("event: %s", event)
|
||||||
|
path = event.path + '/'
|
||||||
if event.dir:
|
if event.dir:
|
||||||
path = event.path
|
|
||||||
wd = self.wm.get_wd(path)
|
|
||||||
self.logger.info("Removing watch on: %s wd %s", path, wd)
|
|
||||||
self.wm.rm_watch(wd, rec=True)
|
|
||||||
if "-unknown-path" in path:
|
|
||||||
pos = path.find("-unknown-path")
|
|
||||||
path = path[0:pos]
|
|
||||||
|
|
||||||
list = self.api_client.list_all_watched_dirs()
|
list = self.api_client.list_all_watched_dirs()
|
||||||
if path in list:
|
if path in list[u'dirs'].values():
|
||||||
self.logger.info("Requesting the airtime server to remove '%s'", path)
|
self.logger.info("Requesting the airtime server to remove '%s'", path)
|
||||||
res = self.api_client.remove_watched_dir(path)
|
res = self.api_client.remove_watched_dir(path)
|
||||||
if(res is None):
|
if(res is None):
|
||||||
|
@ -89,8 +86,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.logger.info("%s removed from watch folder list successfully.", path)
|
self.logger.info("%s removed from watch folder list successfully.", path)
|
||||||
else:
|
else:
|
||||||
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
|
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
|
||||||
else:
|
|
||||||
self.file_events.append({'mode': self.config.MODE_DELETE_DIR, 'filepath': path})
|
|
||||||
|
|
||||||
#event.dir: True if the event was raised against a directory.
|
#event.dir: True if the event was raised against a directory.
|
||||||
#event.name: filename
|
#event.name: filename
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue