CC-3770: Make sure files in /srv/airtime/stor have world-readable permissions.
-fixed
This commit is contained in:
parent
91d1dfbbfa
commit
d997047f5e
|
@ -152,11 +152,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
else:
|
||||
#ensure file is world readable (Liquidsoap and Web UI preview)
|
||||
if self.mmc.make_readable(pathname):
|
||||
is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory)
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
|
||||
else:
|
||||
self.logger.warn("Couldn't add %s because failed to change file permissions", pathname)
|
||||
is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory)
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
|
||||
|
||||
|
||||
def process_IN_MODIFY(self, event):
|
||||
# if IN_MODIFY is followed by IN_CREATE, it's not true modify event
|
||||
|
@ -173,7 +171,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.create_dict[pathname] = time.time()
|
||||
if not dir and not self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
||||
self.logger.info("Modified: %s", pathname)
|
||||
if self.mmc.is_audio_file(name) and self.mmc.make_readable(pathname):
|
||||
if self.mmc.is_audio_file(name):
|
||||
self.file_events.append({'filepath': pathname, 'mode': self.config.MODE_MODIFY})
|
||||
|
||||
# if change is detected on /etc/mtab, we check what mount(file system) was added/removed
|
||||
|
@ -237,51 +235,50 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
|
||||
if not event.dir:
|
||||
if self.mmc.is_audio_file(event.name):
|
||||
if self.mmc.make_readable(event.pathname):
|
||||
if event.cookie in self.temp_files:
|
||||
self.file_events.append({'filepath': event.pathname, 'mode': self.config.MODE_MODIFY})
|
||||
del self.temp_files[event.cookie]
|
||||
elif event.cookie in self.cookies_IN_MOVED_FROM:
|
||||
#files original location was also in a watched directory
|
||||
del self.cookies_IN_MOVED_FROM[event.cookie]
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||
filepath = self.mmc.organize_new_file(event.pathname)
|
||||
|
||||
#delete files from organize if they can not be read properly.
|
||||
if filepath is None:
|
||||
try:
|
||||
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
||||
os.remove(event.pathname)
|
||||
return
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
if event.cookie in self.temp_files:
|
||||
self.file_events.append({'filepath': event.pathname, 'mode': self.config.MODE_MODIFY})
|
||||
del self.temp_files[event.cookie]
|
||||
elif event.cookie in self.cookies_IN_MOVED_FROM:
|
||||
#files original location was also in a watched directory
|
||||
del self.cookies_IN_MOVED_FROM[event.cookie]
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||
filepath = self.mmc.organize_new_file(event.pathname)
|
||||
|
||||
#delete files from organize if they can not be read properly.
|
||||
if filepath is None:
|
||||
try:
|
||||
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
||||
os.remove(event.pathname)
|
||||
return
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
|
||||
else:
|
||||
filepath = event.pathname
|
||||
|
||||
if (filepath is not None):
|
||||
self.file_events.append({'filepath': filepath, 'mode': self.config.MODE_MOVED})
|
||||
else:
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||
filepath = self.mmc.organize_new_file(event.pathname)
|
||||
|
||||
#delete files from organize if they can not be read properly.
|
||||
if filepath is None:
|
||||
try:
|
||||
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
||||
os.remove(event.pathname)
|
||||
return
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
filepath = event.pathname
|
||||
|
||||
if (filepath is not None):
|
||||
self.file_events.append({'filepath': filepath, 'mode': self.config.MODE_MOVED})
|
||||
else:
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||
filepath = self.mmc.organize_new_file(event.pathname)
|
||||
|
||||
#delete files from organize if they can not be read properly.
|
||||
if filepath is None:
|
||||
try:
|
||||
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
||||
os.remove(event.pathname)
|
||||
return
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
else:
|
||||
#show dragged from unwatched folder into a watched folder. Do not "organize".:q!
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
||||
is_recorded = True
|
||||
else:
|
||||
#show dragged from unwatched folder into a watched folder. Do not "organize".:q!
|
||||
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
||||
is_recorded = True
|
||||
else:
|
||||
is_recorded = False
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': is_recorded})
|
||||
is_recorded = False
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': is_recorded})
|
||||
else:
|
||||
#When we move a directory into a watched_dir, we only get a notification that the dir was created,
|
||||
#and no additional information about files that came along with that directory.
|
||||
|
|
|
@ -104,9 +104,8 @@ class MediaMonitorCommon:
|
|||
original_file = pathname
|
||||
is_dir = False
|
||||
try:
|
||||
while not is_readable(original_file, is_dir):
|
||||
while not self.is_readable(original_file, is_dir):
|
||||
#Not readable. Make appropriate permission changes.
|
||||
|
||||
self.make_file_readable(pathname, is_dir)
|
||||
|
||||
dirname = os.path.dirname(pathname)
|
||||
|
@ -315,6 +314,9 @@ class MediaMonitorCommon:
|
|||
|
||||
self.logger.debug("Moving from %s to %s", pathname, filepath)
|
||||
self.move_file(pathname, filepath)
|
||||
if not self.mmc.make_readable(filepath):
|
||||
self.logger.warn("Couldn't make filepath %s readable", pathname)
|
||||
filepath = None
|
||||
else:
|
||||
filepath = None
|
||||
self.logger.warn("File %s, has invalid metadata", pathname)
|
||||
|
|
Loading…
Reference in New Issue