Update sftp.ts

This commit is contained in:
Eugene 2024-07-15 22:56:18 +02:00
parent 1f2bf12ed7
commit ec8ccb5d43
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -91,24 +91,22 @@ export class SFTPSession {
} }
readlink (p: string): Promise<string> { readlink (p: string): Promise<string> {
throw new Error('Not implemented') this.logger.debug('readlink', p)
// this.logger.debug('readlink', p) return this.sftp.readlink(p)
// return wrapPromise(this.zone, promisify<string>(f => this.sftp.readlink(p, f))())
} }
async stat (p: string): Promise<SFTPFile> { async stat (p: string): Promise<SFTPFile> {
throw new Error('Not implemented') this.logger.debug('stat', p)
// this.logger.debug('stat', p) const stats = await this.sftp.stat(p)
// const stats = await wrapPromise(this.zone, promisify<Stats>(f => this.sftp.stat(p, f))()) return {
// return { name: posixPath.basename(p),
// name: posixPath.basename(p), fullPath: p,
// fullPath: p, isDirectory: stats.type === russh.SFTPFileType.Directory,
// isDirectory: stats.isDirectory(), isSymlink: stats.type === russh.SFTPFileType.Symlink,
// isSymlink: stats.isSymbolicLink(), mode: stats.permissions ?? 0,
// mode: stats.mode, size: stats.size,
// size: stats.size, modified: new Date((stats.mtime ?? 0) * 1000),
// modified: new Date(stats.mtime * 1000), }
// }
} }
async open (p: string, mode: string): Promise<SFTPFileHandle> { async open (p: string, mode: string): Promise<SFTPFileHandle> {
@ -127,9 +125,8 @@ export class SFTPSession {
} }
async rename (oldPath: string, newPath: string): Promise<void> { async rename (oldPath: string, newPath: string): Promise<void> {
throw new Error('Not implemented') this.logger.debug('rename', oldPath, newPath)
// this.logger.debug('rename', oldPath, newPath) await this.sftp.rename(oldPath, newPath)
// await promisify((f: any) => this.sftp.rename(oldPath, newPath, f))()
} }
async unlink (p: string): Promise<void> { async unlink (p: string): Promise<void> {
@ -137,9 +134,8 @@ export class SFTPSession {
} }
async chmod (p: string, mode: string|number): Promise<void> { async chmod (p: string, mode: string|number): Promise<void> {
throw new Error('Not implemented') this.logger.debug('chmod', p, mode)
// this.logger.debug('chmod', p, mode) await this.sftp.chmod(p, mode)
// await promisify((f: any) => this.sftp.chmod(p, mode, f))()
} }
async upload (path: string, transfer: FileUpload): Promise<void> { async upload (path: string, transfer: FileUpload): Promise<void> {
@ -192,11 +188,11 @@ export class SFTPSession {
return { return {
fullPath: p, fullPath: p,
name: posixPath.basename(p), name: posixPath.basename(p),
isDirectory: entry.type === russh.SFTPFileType.Directory, isDirectory: entry.metadata.type === russh.SFTPFileType.Directory,
isSymlink: entry.type === russh.SFTPFileType.Symlink, isSymlink: entry.metadata.type === russh.SFTPFileType.Symlink,
mode: entry.permissions ?? 0, mode: entry.metadata.permissions ?? 0,
size: entry.objectSize, size: entry.metadata.size,
modified: new Date((entry.mtime ?? 0) * 1000), modified: new Date((entry.metadata.mtime ?? 0) * 1000),
} }
} }
} }