CC-2595 : Apache error when addWatchedDir() from MusicDir.php is called

need to make this work for new installs.
This commit is contained in:
Naomi Aro 2011-07-27 10:41:33 +02:00
parent b46abe0234
commit 8b9cfd7cfa
1 changed files with 23 additions and 19 deletions

View File

@ -150,31 +150,35 @@ class MusicDir {
->filterByType('link') ->filterByType('link')
->findOne(); ->findOne();
//newly added watched directory object //see if any linked files exist.
$propel_new_watch = CcMusicDirsQuery::create() if (isset($propel_link_dir)) {
->filterByDirectory(realpath($p_path)."/")
->findOne();
//any files of the deprecated "link" type. //newly added watched directory object
$link_files = CcFilesQuery::create() $propel_new_watch = CcMusicDirsQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) ->filterByDirectory(realpath($p_path)."/")
->filterByDbDirectory($propel_link_dir->getId()) ->findOne();
->find();
$newly_watched_dir = $propel_new_watch->getDirectory(); //any files of the deprecated "link" type.
$link_files = CcFilesQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->filterByDbDirectory($propel_link_dir->getId())
->find();
foreach ($link_files as $link_file) { $newly_watched_dir = $propel_new_watch->getDirectory();
$link_filepath = $link_file->getDbFilepath();
//convert "link" file into a watched file. foreach ($link_files as $link_file) {
if ((strlen($newly_watched_dir) < strlen($link_filepath)) && (substr($link_filepath, 0, strlen($newly_watched_dir)) === $newly_watched_dir)) { $link_filepath = $link_file->getDbFilepath();
//get the filepath path not including the watched directory. //convert "link" file into a watched file.
$sub_link_filepath = substr($link_filepath, strlen($newly_watched_dir)); if ((strlen($newly_watched_dir) < strlen($link_filepath)) && (substr($link_filepath, 0, strlen($newly_watched_dir)) === $newly_watched_dir)) {
$link_file->setDbDirectory($propel_new_watch->getId()); //get the filepath path not including the watched directory.
$link_file->setDbFilepath($sub_link_filepath); $sub_link_filepath = substr($link_filepath, strlen($newly_watched_dir));
$link_file->save();
$link_file->setDbDirectory($propel_new_watch->getId());
$link_file->setDbFilepath($sub_link_filepath);
$link_file->save();
}
} }
} }