Пример #1
0
    def synchronize_db_with_collection(self, root_phys_path, dirs, files):
        # only index files that have correct name - it will be changed anyway during next Runner loop
        files = sorted([f for f in files if is_jpeg(f) and Renamer.CORRECT_FILENAME_RE.match(f) or is_video(f)])

        # find directory object corresponding to root -> create if needed
        root_web_path = locations.collection_web_path(root_phys_path)
        root_object = find_or_create_directory(root_web_path)

        self._process_directories(dirs, root_object, root_web_path)

        self._process_files(files, root_object, root_phys_path)
Пример #2
0
 def _name_original_to_miniature(self, f):
     if os.path.exists(f):
         timestamp = get_mtime_datetime(f)
     else:
         try:
             directory, filename = os.path.split(locations.collection_web_path(f))
             timestamp = File.objects.all().get(name=filename, directory__path=directory).modification_time
             timestamp = timestamp.astimezone(tzlocal.get_localzone())
         except File.DoesNotExist:
             raise Exception("File should either exist or be present on database " + f)
     return f + "_" + timestamp.strftime(TIMESTAMP_FORMAT) + self.extension()