def removeAsset(self, path): frsPath = self.frspath(path) if self.exists(frsPath): self.rmtree(frsPath) if self.exists(path): if self.isfile(path): self.remove(path) else: self.rmtree(path) CacheMixin.removeCache(self, path)
def moveAsset(self, src, dst): """ rename or move a file or folder """ frsSrc = self.frspath(src) if self.exists(frsSrc): frsDst = self.frspath(dst) if not self.exists( self.dirname(frsDst) ): self.makedirs(self.dirname(frsDst)) self.move(frsSrc, frsDst ) if not self.exists( self.dirname(dst) ): self.makedirs( self.dirname(dst) ) self.move(src, dst) CacheMixin.moveCache(self, src, dst)
def moveAsset(self, src, dst): """ rename or move a file or folder """ frsSrc = self.frspath(src) if self.exists(frsSrc): frsDst = self.frspath(dst) if not self.exists(self.dirname(frsDst)): self.makedirs(self.dirname(frsDst)) self.move(frsSrc, frsDst) if not self.exists(self.dirname(dst)): self.makedirs(self.dirname(dst)) self.move(src, dst) CacheMixin.moveCache(self, src, dst)
def copyAsset(self, src, dst, copy_archiveinfo=False, **kw): """ copy folder / file and associated manifest/subfiles, not include archives don't keep stat """ if self.isfile(src): self.copyfile(src, dst) else: # copy folder if not self.exists(dst): self.makedirs(dst) for name in self.listdir(src): self.copyAsset(self.joinpath(src, name), self.joinpath(dst, name), copycache=0) # TODO : should be more generic, copy all file/folder except archived # copy manifest # generate new uid when copy if self.version == '': self.genManifestUID(dst, self.getManifest(src) ) # copy subfiles too srcSubfolder = self.subfilespath(src) if self.exists(srcSubfolder): dstSubfolder = self.subfilespath(dst) m_dir_path = self.dirname(dstSubfolder) if not self.exists(m_dir_path): self.makedirs(m_dir_path) self.copytree(srcSubfolder, dstSubfolder) elif self.version == 'json': metadata = self.getMetadata(src) # how to uid? #复制后的新id为0,将在其他地方以intid替换 metadata['zope']['id'] = 0 self.saveMetadata(dst, metadata) # copy archiveinfo file if copy_archiveinfo: srcArchivePath = self.archiveinfopath(src) if self.exists(srcArchivePath): dstArchivePath = self.archiveinfopath(dst) m_dir_path = self.dirname(dstArchivePath) if not self.exists(m_dir_path): self.makedirs(m_dir_path) self.copyfile(srcArchivePath, dstArchivePath) # copy cache CacheMixin.copyCache(self, src,dst)
def copyAsset(self, src, dst, **kw): """ copy folder / file and associated subfiles, not include archives don't keep stat """ if self.isfile(src): self.copyfile(src, dst) else: # copy folder if not self.exists(dst): self.makedirs(dst) for name in self.listdir(src): self.copyAsset(self.joinpath(src, name), self.joinpath(dst, name), copycache=0) # copy cache CacheMixin.copyCache(self, src,dst)
def copyAsset(self, src, dst, **kw): """ copy folder / file and associated subfiles, not include archives don't keep stat """ if self.isfile(src): self.copyfile(src, dst) else: # copy folder if not self.exists(dst): self.makedirs(dst) for name in self.listdir(src): self.copyAsset(self.joinpath(src, name), self.joinpath(dst, name), copycache=0) # copy cache CacheMixin.copyCache(self, src, dst)
def moveAsset(self, src, dst): """ rename or move a file or folder """ frsSrc = self.frspath(src) if self.exists(frsSrc): frsDst = self.frspath(dst) if not self.exists( self.dirname(frsDst) ): self.makedirs(self.dirname(frsDst)) self.move(frsSrc, frsDst ) if not self.exists( self.dirname(dst) ): self.makedirs( self.dirname(dst) ) self.move(src, dst) #if self.version == 'json': # me = self.getMetadata(dst) # # how to uid? # #移动后文件的intid也改变了,这里把id置为0,将在其他地方以intid替换 # me.metadata['zope']['id'] = 0 # self.saveMetadata(dst, me.metadata ) CacheMixin.moveCache(self, src, dst)