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){
|
||||
$file->delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->view->id = $file->getId();
|
||||
}
|
||||
|
|
|
@ -284,10 +284,6 @@ class Application_Model_MusicDir {
|
|||
$real_path = realpath($p_dir)."/";
|
||||
if($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);
|
||||
if($dir == NULL){
|
||||
|
|
|
@ -42,18 +42,16 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
|
||||
def process_IN_MOVE_SELF(self, event):
|
||||
self.logger.info("event: %s", event)
|
||||
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 event.dir:
|
||||
if "-unknown-path" in path:
|
||||
unkown_path = path
|
||||
pos = path.find("-unknown-path")
|
||||
path = path[0:pos]
|
||||
path = path[0:pos]+"/"
|
||||
|
||||
list = self.api_client.list_all_watched_dirs()
|
||||
# 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)
|
||||
res = self.api_client.remove_watched_dir(path)
|
||||
if(res is None):
|
||||
|
@ -64,22 +62,21 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
else:
|
||||
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
|
||||
else:
|
||||
# subdir being moved
|
||||
# in this case, it has to remove watch manualy and also have to manually delete all records
|
||||
# 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):
|
||||
self.logger.info("event: %s", event)
|
||||
path = event.path + '/'
|
||||
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()
|
||||
if path in list:
|
||||
if path in list[u'dirs'].values():
|
||||
self.logger.info("Requesting the airtime server to remove '%s'", path)
|
||||
res = self.api_client.remove_watched_dir(path)
|
||||
if(res is None):
|
||||
|
@ -89,8 +86,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
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:
|
||||
self.file_events.append({'mode': self.config.MODE_DELETE_DIR, 'filepath': path})
|
||||
|
||||
#event.dir: True if the event was raised against a directory.
|
||||
#event.name: filename
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue