CC-2562 : Allow users to convert linked files into watched directories

This commit is contained in:
Naomi Aro 2011-07-25 16:21:42 +02:00
parent 0b5e3a54b4
commit 96284a2a44
3 changed files with 15 additions and 5 deletions

View File

@ -449,11 +449,11 @@ class ApiController extends Zend_Controller_Action
if (is_null($file)) {
$file = StoredFile::Insert($md);
} else {
}
else {
$this->view->error = "File already exists in Airtime.";
return;
}
}
else if ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];

View File

@ -150,21 +150,29 @@ class MusicDir {
->filterByType('link')
->findOne();
//newly added watched directory object
$propel_new_watch = CcMusicDirsQuery::create()
->filterByDirectory(realpath($p_path)."/")
->findOne();
//any files of the deprecated "link" type.
$link_files = CcFilesQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->filterByDbDirectory($propel_link_dir->getId())
->find();
$newly_watched_dir = $propel_new_watch->getDirectory();
foreach ($link_files as $link_file) {
$link_filepath = $link_file->getDbFilepath();
//convert "link" file into a watched file.
if ((strlen($propel_link_dir->getDirectory()) < $link_filepath) && (substr($link_filepath, 0, strlen($propel_link_dir->getDirectory())) === $propel_link_dir->getDirectory())) {
if ((strlen($newly_watched_dir) < strlen($link_filepath)) && (substr($link_filepath, 0, strlen($newly_watched_dir)) === $newly_watched_dir)) {
//get the filepath path not including the watched directory.
$sub_link_filepath = substr($link_filepath, strlen($propel_link_dir->getDirectory()));
$sub_link_filepath = substr($link_filepath, strlen($newly_watched_dir));
$link_file->setDbDirectory($propel_link_dir->getId());
$link_file->setDbDirectory($propel_new_watch->getId());
$link_file->setDbFilepath($sub_link_filepath);
$link_file->save();
}
@ -253,6 +261,7 @@ class MusicDir {
public static function getWatchedDirFromFilepath($p_filepath)
{
$dirs = CcMusicDirsQuery::create()
->filterByType(array("watched", "stor"))
->find();
foreach($dirs as $dir) {

View File

@ -507,6 +507,7 @@ class StoredFile {
}
else if (isset($p_filepath)) {
$path_info = MusicDir::splitFilePath($p_filepath);
if (is_null($path_info)) {
return null;
}