def _file_attr(self, mtime=0): attr = SFTPAttributes() attr.st_uid = os.getuid() attr.st_gid = os.getgid() attr.st_mode = stat.S_IRUSR + stat.S_IFREG attr.st_mtime = mtime attr.st_atime = mtime attr.st_ctime = mtime return attr
def _dir_attr(self, mtime=0): attr = SFTPAttributes() attr.st_size = 1 attr.st_uid = os.getuid() attr.st_gid = os.getgid() attr.st_mtime = mtime attr.st_atime = mtime attr.st_ctime = mtime attr.st_mode = stat.S_IRUSR + stat.S_IXUSR + stat.S_IFDIR return attr
def blob_to_stat(blob): attr = SFTPAttributes() attr.st_mode = 0o0100666 if (blob == None or isinstance(blob, DirectoryBlob)): attr.st_mode &= ~stat.S_IFREG attr.st_mode |= stat.S_IFDIR attr.st_mode |= 0o777 if blob == None: #Assume non-existing files are directories return attr attr.filename = blob.name.strip("/").rsplit("/", 1)[-1] attr.st_size = blob.size attr.st_uid = 1000 attr.st_gid = 1000 ts = blob.time_created.timestamp() attr.st_ctime = ts attr.st_mtime = blob.updated.timestamp() if blob.updated else ts attr.st_atime = blob.updated.timestamp() if blob.updated else ts return attr