MCPcopy
hub / github.com/Eugeny/tabby / upload

Method upload

tabby-ssh/src/session/sftp.ts:113–134  ·  view source on GitHub ↗
(path: string, transfer: FileUpload)

Source from the content-addressed store, hash-verified

111 }
112
113 async upload (path: string, transfer: FileUpload): Promise<void> {
114 this.logger.info('Uploading into', path)
115 const tempPath = path + '.tabby-upload'
116 try {
117 const handle = await this.open(tempPath, russh.OPEN_WRITE | russh.OPEN_CREATE)
118 while (true) {
119 const chunk = await transfer.read()
120 if (!chunk.length) {
121 break
122 }
123 await handle.write(chunk)
124 }
125 await handle.close()
126 await this.unlink(path).catch(() => null)
127 await this.rename(tempPath, path)
128 transfer.close()
129 } catch (e) {
130 transfer.cancel()
131 this.unlink(tempPath).catch(() => null)
132 throw e
133 }
134 }
135
136 async download (path: string, transfer: FileDownload): Promise<void> {
137 this.logger.info('Downloading', path)

Callers 1

editMethod · 0.45

Calls 8

openMethod · 0.95
unlinkMethod · 0.95
renameMethod · 0.95
infoMethod · 0.80
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected