CC-3561: Add button to automatically rescan watched folders.
-done
This commit is contained in:
parent
70bfe031ef
commit
d02607ed94
|
@ -353,10 +353,12 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function rescanWatchDirectoryAction()
|
public function rescanWatchDirectoryAction()
|
||||||
{
|
{
|
||||||
$dirs = Application_Model_MusicDir::getWatchedDirs();
|
$dir = Application_Model_MusicDir::getDirByPath($this->getRequest()->getParam("dir"));
|
||||||
foreach ($dirs as $dir) {
|
$id = $dir->getId();
|
||||||
$res = Application_Model_MusicDir::addWatchedDir($dir->getDirectory());
|
$data = array();
|
||||||
}
|
$data['directory'] = $dir->getDirectory();
|
||||||
|
$data['id'] = $id;
|
||||||
|
Application_Model_RabbitMq::SendMessageToMediaMonitor('rescan_watch', $data);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<dt id="watchedFolder-label" class="block-display">
|
<dt id="watchedFolder-label" class="block-display">
|
||||||
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>
|
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>
|
||||||
<a href="#" id="watchedFolder-rescan">Rescan</a>
|
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="watchedFolder-element" class="block-display">
|
<dd id="watchedFolder-element" class="block-display">
|
||||||
<?php echo $this->element->getElement('watchedFolder') ?>
|
<?php echo $this->element->getElement('watchedFolder') ?>
|
||||||
|
@ -39,7 +39,10 @@
|
||||||
<?php if (count($watched_dirs) > 0): ?>
|
<?php if (count($watched_dirs) > 0): ?>
|
||||||
<?php foreach($watched_dirs as $watched_dir): ?>
|
<?php foreach($watched_dirs as $watched_dir): ?>
|
||||||
<dd class="block-display selected-item">
|
<dd class="block-display selected-item">
|
||||||
<?php echo ($watched_dir->getExistsFlag())?"":"<span class='ui-icon-alert'><img src='/css/images/warning-icon.png'></span>"?><span><?php echo $watched_dir->getDirectory();?></span></span><span class="ui-icon ui-icon-close"></span>
|
<?php echo ($watched_dir->getExistsFlag())?"":"<span class='ui-icon-alert'><img src='/css/images/warning-icon.png'></span>"?><span id="folderPath"><?php echo $watched_dir->getDirectory();?></span></span>
|
||||||
|
<span title="Rescan watched directory (This is useful if it is network mount and may be out of sync with Airtime)" class="ui-icon ui-icon-refresh"></span>
|
||||||
|
<span title="Remove watched directory" class="ui-icon ui-icon-close"></span>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
|
@ -2027,12 +2027,23 @@ label span {
|
||||||
-moz-border-radius: 4px;
|
-moz-border-radius: 4px;
|
||||||
font-size:13px;
|
font-size:13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#watched-folder-section dd.block-display.selected-item .ui-icon {
|
#watched-folder-section dd.block-display.selected-item .ui-icon {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:4px;
|
top:4px;
|
||||||
right:5px;
|
right:5px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#watched-folder-section dd.block-display.selected-item .ui-icon.ui-icon-refresh {
|
||||||
|
position:absolute;
|
||||||
|
top:4px;
|
||||||
|
right:20px;
|
||||||
|
cursor:pointer;
|
||||||
|
background-image:url(redmond/images/ui-icons_ffffff_256x240.png);
|
||||||
|
background-position: -128px -63px;
|
||||||
|
}
|
||||||
|
|
||||||
#watched-folder-section dd.block-display.selected-item .ui-icon:hover {
|
#watched-folder-section dd.block-display.selected-item .ui-icon:hover {
|
||||||
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png)
|
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png)
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,14 +78,15 @@ function setWatchedDirEvents() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#watchedFolder-rescan').click(function(){
|
$('.selected-item').find('.ui-icon-refresh').click(function(){
|
||||||
$.get("/Preference/rescan-watch-directory", {format: "json"});
|
var folder = $(this).prev().text();
|
||||||
|
$.get("/Preference/rescan-watch-directory", {format: "json", dir: folder});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.selected-item').find('.ui-icon-close').click(function(){
|
$('.selected-item').find('.ui-icon-close').click(function(){
|
||||||
if(confirm("Are you sure you want to remove the watched folder?")){
|
if(confirm("Are you sure you want to remove the watched folder?")){
|
||||||
var row = $(this).parent();
|
var row = $(this).parent();
|
||||||
var folder = $(this).prev().text();
|
var folder = row.find('#folderPath').text();
|
||||||
|
|
||||||
url = "/Preference/remove-watch-directory";
|
url = "/Preference/remove-watch-directory";
|
||||||
|
|
||||||
|
@ -124,4 +125,5 @@ $(document).ready(function() {
|
||||||
show: 'mouseover',
|
show: 'mouseover',
|
||||||
hide: 'mouseout'
|
hide: 'mouseout'
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,9 +109,9 @@ class AirtimeMediaMonitorBootstrap():
|
||||||
if os.path.exists(self.mmc.timestamp_file):
|
if os.path.exists(self.mmc.timestamp_file):
|
||||||
"""find files that have been modified since the last time media-monitor process started."""
|
"""find files that have been modified since the last time media-monitor process started."""
|
||||||
time_diff_sec = time.time() - os.path.getmtime(self.mmc.timestamp_file)
|
time_diff_sec = time.time() - os.path.getmtime(self.mmc.timestamp_file)
|
||||||
command = "find %s -iname '*.ogg' -o -iname '*.mp3' -type f -readable -mmin -%d" % (dir, time_diff_sec/60+1)
|
command = "find '%s' -iname '*.ogg' -o -iname '*.mp3' -type f -readable -mmin -%d" % (dir, time_diff_sec/60+1)
|
||||||
else:
|
else:
|
||||||
command = "find %s -iname '*.ogg' -o -iname '*.mp3' -type f -readable" % dir
|
command = "find '%s' -iname '*.ogg' -o -iname '*.mp3' -type f -readable" % dir
|
||||||
|
|
||||||
self.logger.debug(command)
|
self.logger.debug(command)
|
||||||
stdout = self.mmc.exec_command(command)
|
stdout = self.mmc.exec_command(command)
|
||||||
|
|
|
@ -84,6 +84,9 @@ class AirtimeNotifier(Notifier):
|
||||||
self.logger.info("Removing watch on: %s wd %s", watched_directory, wd)
|
self.logger.info("Removing watch on: %s wd %s", watched_directory, wd)
|
||||||
mm.wm.rm_watch(wd, rec=True)
|
mm.wm.rm_watch(wd, rec=True)
|
||||||
|
|
||||||
|
elif m['event_type'] == "rescan_watch":
|
||||||
|
self.bootstrap.sync_database_to_filesystem(str(m['id']), m['directory'])
|
||||||
|
|
||||||
elif m['event_type'] == "change_stor":
|
elif m['event_type'] == "change_stor":
|
||||||
storage_directory = self.config.storage_directory
|
storage_directory = self.config.storage_directory
|
||||||
new_storage_directory = m['directory']
|
new_storage_directory = m['directory']
|
||||||
|
|
Loading…
Reference in New Issue