Updated edit in fs to use upload
This commit is contained in:
@@ -89,17 +89,15 @@
|
|||||||
error = ''
|
error = ''
|
||||||
try {
|
try {
|
||||||
const filePath = currentPath === '/' ? `/${selectedFile}` : `${currentPath}/${selectedFile}`
|
const filePath = currentPath === '/' ? `/${selectedFile}` : `${currentPath}/${selectedFile}`
|
||||||
const content = new TextEncoder().encode(fileContent)
|
const data = new TextEncoder().encode(fileContent)
|
||||||
|
|
||||||
const result = await api.post_proto<Response>('/api/files/edit', {
|
const result = await fileSystemClient.uploadFile(filePath, data)
|
||||||
fileEditRequest: { path: filePath, content }
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result.ok && result.value.statusCode === 200) {
|
if (result.success) {
|
||||||
isEditing = false
|
isEditing = false
|
||||||
await loadDirectory() // Refresh to update file sizes
|
await loadDirectory() // Refresh to update file sizes
|
||||||
} else {
|
} else {
|
||||||
error = result.ok ? result.value.errorMessage || 'Failed to save file' : 'Failed to save file'
|
error = result.error || 'Failed to save file'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e instanceof Error ? e.message : 'Failed to save file'
|
error = e instanceof Error ? e.message : 'Failed to save file'
|
||||||
@@ -196,10 +194,12 @@
|
|||||||
fileMkdirRequest: { path }
|
fileMkdirRequest: { path }
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.ok && result.value.statusCode === 200) {
|
if (result.isOk() && result.inner.statusCode === 200) {
|
||||||
await loadDirectory()
|
await loadDirectory()
|
||||||
|
} else if (result.isErr()) {
|
||||||
|
error = 'Failed to create directory'
|
||||||
} else {
|
} else {
|
||||||
error = result.ok ? result.value.errorMessage || 'Failed to create directory' : 'Failed to create directory'
|
error = result.inner.errorMessage || 'Failed to create directory'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e instanceof Error ? e.message : 'Error creating directory'
|
error = e instanceof Error ? e.message : 'Error creating directory'
|
||||||
@@ -213,15 +213,13 @@
|
|||||||
const path = currentPath === '/' ? `/${fileName}` : `${currentPath}/${fileName}`
|
const path = currentPath === '/' ? `/${fileName}` : `${currentPath}/${fileName}`
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await api.post_proto<Response>('/api/files/edit', {
|
const result = await fileSystemClient.uploadFile(path, new Uint8Array(0))
|
||||||
fileEditRequest: { path, content: new Uint8Array(0) }
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result.ok && result.value.statusCode === 200) {
|
if (result.success) {
|
||||||
await loadDirectory()
|
await loadDirectory()
|
||||||
await loadFileContent(fileName)
|
await loadFileContent(fileName)
|
||||||
} else {
|
} else {
|
||||||
error = result.ok ? result.value.errorMessage || 'Failed to create file' : 'Failed to create file'
|
error = result.error || 'Failed to create file'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e instanceof Error ? e.message : 'Error creating file'
|
error = e instanceof Error ? e.message : 'Error creating file'
|
||||||
|
|||||||
@@ -13,3 +13,8 @@ api.FileList.entries type:FT_POINTER
|
|||||||
api.Response.error_message type:FT_POINTER
|
api.Response.error_message type:FT_POINTER
|
||||||
|
|
||||||
api.FileDeleteRequest.path max_size:128
|
api.FileDeleteRequest.path max_size:128
|
||||||
|
|
||||||
|
api.FileEditRequest.path max_size:128
|
||||||
|
api.FileEditRequest.content type:FT_POINTER
|
||||||
|
|
||||||
|
api.FileMkdirRequest.path max_size:128
|
||||||
|
|||||||
Reference in New Issue
Block a user