CC-2562 : Allow users to convert linked files into watched directories
This commit is contained in:
parent
79f8bb8af9
commit
0b5e3a54b4
|
@ -144,6 +144,32 @@ class MusicDir {
|
||||||
{
|
{
|
||||||
$res = self::addDir($p_path, "watched");
|
$res = self::addDir($p_path, "watched");
|
||||||
if ($res['code'] == 0){
|
if ($res['code'] == 0){
|
||||||
|
|
||||||
|
//convert "linked" files (Airtime <= 1.8.2) to watched files.
|
||||||
|
$propel_link_dir = CcMusicDirsQuery::create()
|
||||||
|
->filterByType('link')
|
||||||
|
->findOne();
|
||||||
|
|
||||||
|
$link_files = CcFilesQuery::create()
|
||||||
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||||
|
->filterByDbDirectory($propel_link_dir->getId())
|
||||||
|
->find();
|
||||||
|
|
||||||
|
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())) {
|
||||||
|
|
||||||
|
//get the filepath path not including the watched directory.
|
||||||
|
$sub_link_filepath = substr($link_filepath, strlen($propel_link_dir->getDirectory()));
|
||||||
|
|
||||||
|
$link_file->setDbDirectory($propel_link_dir->getId());
|
||||||
|
$link_file->setDbFilepath($sub_link_filepath);
|
||||||
|
$link_file->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data["directory"] = $p_path;
|
$data["directory"] = $p_path;
|
||||||
RabbitMq::SendMessageToMediaMonitor("new_watch", $data);
|
RabbitMq::SendMessageToMediaMonitor("new_watch", $data);
|
||||||
|
|
Loading…
Reference in New Issue