def end_unpacking(self, path: Path, unpacked_path: Path, *args, format: AbstractFormat = None, is_collection: bool = False, **kwargs): parent = self.get_uf(path) parent.status = UploadedFile.UNPACKED parent.update() if not is_collection: uf = UploadedFile() uf.status = UploadedFile.UPLOADED # Better status ? uf.contentType = format.get_identifier() # TODO uf.size = unpacked_path.size uf.filename = str(unpacked_path.relative_to(FILE_ROOT_PATH)) uf.originalFilename = str(format.main_path.name) uf.ext = "" uf.storage = parent.storage uf.user = parent.user uf.parent = parent.id uf.imageServer = parent.imageServer uf.save() self.path_uf_mapping[str(unpacked_path)] = uf
def register_file(self, path: Path, parent_path: Path, *args, **kwargs): parent = self.get_uf(parent_path) uf = UploadedFile() uf.status = UploadedFile.UPLOADED uf.contentType = "" uf.size = path.size uf.filename = str(path.relative_to(FILE_ROOT_PATH)) uf.originalFilename = str(path.name) uf.ext = "" uf.storage = parent.storage uf.user = parent.user uf.parent = parent.id uf.imageServer = parent.imageServer uf.save() self.path_uf_mapping[str(path)] = uf
def start_conversion(self, path: Path, parent_path: Path, *args, **kwargs): uf = UploadedFile() uf.status = UploadedFile.CONVERTING uf.originalFilename = path.name uf.filename = str(path.relative_to(FILE_ROOT_PATH)) uf.size = 0 uf.ext = "" uf.contentType = "" parent = self.get_uf(parent_path) uf.storage = parent.storage uf.user = parent.user uf.parent = parent.id uf.imageServer = parent.imageServer uf.save() self.path_uf_mapping[str(path)] = uf parent.status = UploadedFile.CONVERTING parent.update()
def moved_pending_file(self, old_path: Path, new_path: Path, *args, **kwargs): uf = self.get_uf(old_path) uf.filename = str(new_path.relative_to(FILE_ROOT_PATH)) uf.update() self.path_uf_mapping[str(new_path)] = uf