public function updateFileSystemMountAction()
 {
     $request = $this->getRequest();
     $params = $request->getParams();
     $added_list = empty($params['added_dir']) ? array() : explode(',', $params['added_dir']);
     $removed_list = empty($params['removed_dir']) ? array() : explode(',', $params['removed_dir']);
     // get all watched dirs
     $watched_dirs = Application_Model_MusicDir::getWatchedDirs(null, null);
     foreach ($added_list as $ad) {
         $ad .= '/';
         foreach ($watched_dirs as $dir) {
             $dirPath = $dir->getDirectory();
             // if mount path itself was watched
             if ($dirPath == $ad) {
                 Application_Model_MusicDir::addWatchedDir($dirPath, false);
             } elseif (substr($dirPath, 0, strlen($ad)) === $ad && $dir->getExistsFlag() == false) {
                 // if dir contains any dir in removed_list( if watched dir resides on new mounted path )
                 Application_Model_MusicDir::addWatchedDir($dirPath, false);
             } elseif (substr($ad, 0, strlen($dirPath)) === $dirPath) {
                 // is new mount point within the watched dir?
                 // pyinotify doesn't notify anyhing in this case, so we add this mount point as
                 // watched dir
                 // bypass nested loop check
                 Application_Model_MusicDir::addWatchedDir($ad, false, true);
             }
         }
     }
     foreach ($removed_list as $rd) {
         $rd .= '/';
         foreach ($watched_dirs as $dir) {
             $dirPath = $dir->getDirectory();
             // if dir contains any dir in removed_list( if watched dir resides on new mounted path )
             if (substr($dirPath, 0, strlen($rd)) === $rd && $dir->getExistsFlag() == true) {
                 Application_Model_MusicDir::removeWatchedDir($dirPath, false);
             } elseif (substr($rd, 0, strlen($dirPath)) === $dirPath) {
                 // is new mount point within the watched dir?
                 // pyinotify doesn't notify anyhing in this case, so we walk through all files within
                 // this watched dir in DB and mark them deleted.
                 // In case of h) of use cases, due to pyinotify behaviour of noticing mounted dir, we need to
                 // compare agaisnt all files in cc_files table
                 $watchDir = Application_Model_MusicDir::getDirByPath($rd);
                 // get all the files that is under $dirPath
                 $files = Application_Model_StoredFile::listAllFiles($dir->getId(), $all = false);
                 foreach ($files as $f) {
                     // if the file is from this mount
                     if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) {
                         $f->delete();
                     }
                 }
                 if ($watchDir) {
                     Application_Model_MusicDir::removeWatchedDir($rd, false);
                 }
             }
         }
     }
 }