diff --git a/frontend/app/view/preview/directorypreview.tsx b/frontend/app/view/preview/directorypreview.tsx index cccb413e13..2a29c1e5e7 100644 --- a/frontend/app/view/preview/directorypreview.tsx +++ b/frontend/app/view/preview/directorypreview.tsx @@ -664,7 +664,7 @@ const TableRow = React.forwardRef(function ({ idx, handleFileContextMenu, }: TableRowProps) { - const dirPath = useAtomValue(model.normFilePath); + const dirPath = useAtomValue(model.statFilePath); const connection = useAtomValue(model.connection); const dragItem: DraggedFile = { diff --git a/frontend/app/view/preview/preview.tsx b/frontend/app/view/preview/preview.tsx index 0d97ac81d9..27569f0812 100644 --- a/frontend/app/view/preview/preview.tsx +++ b/frontend/app/view/preview/preview.tsx @@ -13,14 +13,7 @@ import { TabRpcClient } from "@/app/store/wshrpcutil"; import { BlockHeaderSuggestionControl } from "@/app/suggestion/suggestion"; import { CodeEditor } from "@/app/view/codeeditor/codeeditor"; import { Markdown } from "@/element/markdown"; -import { - atoms, - getConnStatusAtom, - getOverrideConfigAtom, - getSettingsKeyAtom, - globalStore, - refocusNode, -} from "@/store/global"; +import { getConnStatusAtom, getOverrideConfigAtom, getSettingsKeyAtom, globalStore, refocusNode } from "@/store/global"; import * as services from "@/store/services"; import * as WOS from "@/store/wos"; import { getWebServerEndpoint } from "@/util/endpoints"; @@ -141,8 +134,6 @@ export class PreviewModel implements ViewModel { metaFilePath: Atom; statFilePath: Atom>; - normFilePath: Atom>; - loadableStatFilePath: Atom>; loadableFileInfo: Atom>; connection: Atom>; connectionImmediate: Atom; @@ -341,7 +332,6 @@ export class PreviewModel implements ViewModel { const isCeView = loadableSV.state == "hasData" && loadableSV.data.specializedView == "codeedit"; if (mimeType == "directory") { const showHiddenFiles = get(this.showHiddenFiles); - const settings = get(atoms.settingsAtom); return [ { elemtype: "iconbutton", @@ -379,11 +369,6 @@ export class PreviewModel implements ViewModel { const fileInfo = await get(this.statFile); return fileInfo?.path; }); - this.normFilePath = atom>(async (get) => { - const fileInfo = await get(this.statFile); - return fileInfo?.path; - }); - this.loadableStatFilePath = loadable(this.statFilePath); this.connection = atom>(async (get) => { const connName = get(this.blockAtom)?.meta?.connection; try { @@ -399,7 +384,6 @@ export class PreviewModel implements ViewModel { }); this.statFile = atom>(async (get) => { const fileName = get(this.metaFilePath); - console.log("stat file", fileName); const path = await this.formatRemoteUri(fileName, get); if (fileName == null) { return null; @@ -492,17 +476,13 @@ export class PreviewModel implements ViewModel { async getSpecializedView(getFn: Getter): Promise<{ specializedView?: string; errorStr?: string }> { const mimeType = await getFn(this.fileMimeType); const fileInfo = await getFn(this.statFile); - const fileName = await getFn(this.statFilePath); + const fileName = fileInfo?.name; const connErr = getFn(this.connectionError); const editMode = getFn(this.editMode); - const parentFileInfo = await this.getParentInfo(fileInfo); if (connErr != "") { return { errorStr: `Connection Error: ${connErr}` }; } - if (parentFileInfo?.notfound ?? false) { - return { errorStr: `Parent Directory Not Found: ${fileInfo.path}` }; - } if (fileInfo?.notfound) { return { specializedView: "codeedit" }; } @@ -585,19 +565,6 @@ export class PreviewModel implements ViewModel { globalStore.set(this.newFileContent, null); } - async getParentInfo(fileInfo: FileInfo): Promise { - try { - const parentFileInfo = await RpcApi.FileInfoCommand(TabRpcClient, { - info: { - path: await this.formatRemoteUri(fileInfo.dir, globalStore.get), - }, - }); - return parentFileInfo; - } catch { - return undefined; - } - } - async goParentDirectory({ fileInfo = null }: { fileInfo?: FileInfo | null }) { // optional parameter needed for recursive case const defaultFileInfo = await globalStore.get(this.statFile); @@ -609,18 +576,8 @@ export class PreviewModel implements ViewModel { return true; } try { - const newFileInfo = await RpcApi.FileInfoCommand(TabRpcClient, { - info: { - path: await this.formatRemoteUri(fileInfo.dir, globalStore.get), - }, - }); - if (newFileInfo.path != "" && newFileInfo.notfound) { - console.log("parent does not exist, ", newFileInfo.path); - this.goParentDirectory({ fileInfo: newFileInfo }); - return; - } this.updateOpenFileModalAndError(false); - await this.goHistory(newFileInfo.path); + await this.goHistory(fileInfo.dir); refocusNode(this.blockId); } catch (e) { globalStore.set(this.openFileError, e.message); @@ -725,7 +682,7 @@ export class PreviewModel implements ViewModel { label: "Copy Full Path", click: () => fireAndForget(async () => { - const filePath = await globalStore.get(this.normFilePath); + const filePath = await globalStore.get(this.statFilePath); if (filePath == null) { return; } @@ -949,8 +906,8 @@ function StreamingPreview({ model }: SpecializedViewProps) { function CodeEditPreview({ model }: SpecializedViewProps) { const fileContent = useAtomValue(model.fileContent); const setNewFileContent = useSetAtom(model.newFileContent); - const fileName = useAtomValue(model.statFilePath); const fileInfo = useAtomValue(model.statFile); + const fileName = fileInfo?.name; const blockMeta = useAtomValue(model.blockAtom)?.meta; function codeEditKeyDownHandler(e: WaveKeyboardEvent): boolean { diff --git a/pkg/remote/awsconn/awsconn.go b/pkg/remote/awsconn/awsconn.go index 69e4cab5ed..69b08f75a8 100644 --- a/pkg/remote/awsconn/awsconn.go +++ b/pkg/remote/awsconn/awsconn.go @@ -43,7 +43,6 @@ func GetConfig(ctx context.Context, profile string) (*aws.Config, error) { return nil, fmt.Errorf("invalid connection string: %s)", profile) } profile = connMatch[1] - log.Printf("GetConfig: profile=%s", profile) // TODO: Reimplement generic profile support // profiles, cerrs := wconfig.ReadWaveHomeConfigFile(wconfig.ProfilesFile) diff --git a/pkg/remote/fileshare/fileshare.go b/pkg/remote/fileshare/fileshare.go index 558da7e551..9d1eed196a 100644 --- a/pkg/remote/fileshare/fileshare.go +++ b/pkg/remote/fileshare/fileshare.go @@ -56,6 +56,7 @@ func Read(ctx context.Context, data wshrpc.FileData) (*wshrpc.FileData, error) { } func ReadStream(ctx context.Context, data wshrpc.FileData) <-chan wshrpc.RespOrErrorUnion[wshrpc.FileData] { + log.Printf("ReadStream: %v", data.Info.Path) client, conn := CreateFileShareClient(ctx, data.Info.Path) if conn == nil || client == nil { return wshutil.SendErrCh[wshrpc.FileData](fmt.Errorf(ErrorParsingConnection, data.Info.Path)) @@ -64,6 +65,7 @@ func ReadStream(ctx context.Context, data wshrpc.FileData) <-chan wshrpc.RespOrE } func ReadTarStream(ctx context.Context, data wshrpc.CommandRemoteStreamTarData) <-chan wshrpc.RespOrErrorUnion[iochantypes.Packet] { + log.Printf("ReadTarStream: %v", data.Path) client, conn := CreateFileShareClient(ctx, data.Path) if conn == nil || client == nil { return wshutil.SendErrCh[iochantypes.Packet](fmt.Errorf(ErrorParsingConnection, data.Path)) @@ -72,6 +74,7 @@ func ReadTarStream(ctx context.Context, data wshrpc.CommandRemoteStreamTarData) } func ListEntries(ctx context.Context, path string, opts *wshrpc.FileListOpts) ([]*wshrpc.FileInfo, error) { + log.Printf("ListEntries: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return nil, fmt.Errorf(ErrorParsingConnection, path) @@ -80,6 +83,7 @@ func ListEntries(ctx context.Context, path string, opts *wshrpc.FileListOpts) ([ } func ListEntriesStream(ctx context.Context, path string, opts *wshrpc.FileListOpts) <-chan wshrpc.RespOrErrorUnion[wshrpc.CommandRemoteListEntriesRtnData] { + log.Printf("ListEntriesStream: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return wshutil.SendErrCh[wshrpc.CommandRemoteListEntriesRtnData](fmt.Errorf(ErrorParsingConnection, path)) @@ -88,6 +92,7 @@ func ListEntriesStream(ctx context.Context, path string, opts *wshrpc.FileListOp } func Stat(ctx context.Context, path string) (*wshrpc.FileInfo, error) { + log.Printf("Stat: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return nil, fmt.Errorf(ErrorParsingConnection, path) @@ -96,6 +101,7 @@ func Stat(ctx context.Context, path string) (*wshrpc.FileInfo, error) { } func PutFile(ctx context.Context, data wshrpc.FileData) error { + log.Printf("PutFile: %v", data.Info.Path) client, conn := CreateFileShareClient(ctx, data.Info.Path) if conn == nil || client == nil { return fmt.Errorf(ErrorParsingConnection, data.Info.Path) @@ -104,6 +110,7 @@ func PutFile(ctx context.Context, data wshrpc.FileData) error { } func Mkdir(ctx context.Context, path string) error { + log.Printf("Mkdir: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return fmt.Errorf(ErrorParsingConnection, path) @@ -112,6 +119,7 @@ func Mkdir(ctx context.Context, path string) error { } func Move(ctx context.Context, data wshrpc.CommandFileCopyData) error { + log.Printf("Move: %v", data) srcClient, srcConn := CreateFileShareClient(ctx, data.SrcUri) if srcConn == nil || srcClient == nil { return fmt.Errorf("error creating fileshare client, could not parse source connection %s", data.SrcUri) @@ -140,6 +148,7 @@ func Move(ctx context.Context, data wshrpc.CommandFileCopyData) error { } func Copy(ctx context.Context, data wshrpc.CommandFileCopyData) error { + log.Printf("Copy: %v", data) srcClient, srcConn := CreateFileShareClient(ctx, data.SrcUri) if srcConn == nil || srcClient == nil { return fmt.Errorf("error creating fileshare client, could not parse source connection %s", data.SrcUri) @@ -156,6 +165,7 @@ func Copy(ctx context.Context, data wshrpc.CommandFileCopyData) error { } func Delete(ctx context.Context, data wshrpc.CommandDeleteFileData) error { + log.Printf("Delete: %v", data) client, conn := CreateFileShareClient(ctx, data.Path) if conn == nil || client == nil { return fmt.Errorf(ErrorParsingConnection, data.Path) @@ -164,6 +174,7 @@ func Delete(ctx context.Context, data wshrpc.CommandDeleteFileData) error { } func Join(ctx context.Context, path string, parts ...string) (*wshrpc.FileInfo, error) { + log.Printf("Join: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return nil, fmt.Errorf(ErrorParsingConnection, path) @@ -172,6 +183,7 @@ func Join(ctx context.Context, path string, parts ...string) (*wshrpc.FileInfo, } func Append(ctx context.Context, data wshrpc.FileData) error { + log.Printf("Append: %v", data.Info.Path) client, conn := CreateFileShareClient(ctx, data.Info.Path) if conn == nil || client == nil { return fmt.Errorf(ErrorParsingConnection, data.Info.Path) @@ -180,6 +192,7 @@ func Append(ctx context.Context, data wshrpc.FileData) error { } func GetCapability(ctx context.Context, path string) (wshrpc.FileShareCapability, error) { + log.Printf("GetCapability: %v", path) client, conn := CreateFileShareClient(ctx, path) if conn == nil || client == nil { return wshrpc.FileShareCapability{}, fmt.Errorf(ErrorParsingConnection, path) diff --git a/pkg/remote/fileshare/s3fs/s3fs.go b/pkg/remote/fileshare/s3fs/s3fs.go index 2130906246..aef9404196 100644 --- a/pkg/remote/fileshare/s3fs/s3fs.go +++ b/pkg/remote/fileshare/s3fs/s3fs.go @@ -53,7 +53,6 @@ func (c S3Client) Read(ctx context.Context, conn *connparse.Connection, data wsh func (c S3Client) ReadStream(ctx context.Context, conn *connparse.Connection, data wshrpc.FileData) <-chan wshrpc.RespOrErrorUnion[wshrpc.FileData] { bucket := conn.Host objectKey := conn.Path - log.Printf("s3fs.ReadStream: %v", conn.GetFullURI()) rtn := make(chan wshrpc.RespOrErrorUnion[wshrpc.FileData], 16) go func() { defer close(rtn) @@ -89,7 +88,6 @@ func (c S3Client) ReadStream(ctx context.Context, conn *connparse.Connection, da Range: aws.String(fmt.Sprintf("bytes=%d-%d", data.At.Offset, data.At.Offset+int64(data.At.Size)-1)), }) } else { - log.Printf("reading %v", conn.GetFullURI()) result, err = c.client.GetObject(ctx, &s3.GetObjectInput{ Bucket: aws.String(bucket), Key: aws.String(objectKey), @@ -117,7 +115,6 @@ func (c S3Client) ReadStream(ctx context.Context, conn *connparse.Connection, da Dir: fsutil.GetParentPath(conn), } fileutil.AddMimeTypeToFileInfo(finfo.Path, finfo) - log.Printf("file info: %v", finfo) rtn <- wshrpc.RespOrErrorUnion[wshrpc.FileData]{Response: wshrpc.FileData{Info: finfo}} if size == 0 { log.Printf("no data to read") @@ -126,10 +123,8 @@ func (c S3Client) ReadStream(ctx context.Context, conn *connparse.Connection, da defer utilfn.GracefulClose(result.Body, "s3fs", conn.GetFullURI()) bytesRemaining := size for { - log.Printf("bytes remaining: %d", bytesRemaining) select { case <-ctx.Done(): - log.Printf("context done") rtn <- wshutil.RespErr[wshrpc.FileData](context.Cause(ctx)) return default: @@ -139,7 +134,6 @@ func (c S3Client) ReadStream(ctx context.Context, conn *connparse.Connection, da rtn <- wshutil.RespErr[wshrpc.FileData](err) return } - log.Printf("read %d bytes", n) if n == 0 { break } @@ -488,7 +482,6 @@ func (c S3Client) ListEntriesStream(ctx context.Context, conn *connparse.Connect } func (c S3Client) Stat(ctx context.Context, conn *connparse.Connection) (*wshrpc.FileInfo, error) { - log.Printf("Stat: %v", conn.GetFullURI()) bucketName := conn.Host objectKey := conn.Path if bucketName == "" || bucketName == fspath.Separator { @@ -604,7 +597,6 @@ func (c S3Client) Stat(ctx context.Context, conn *connparse.Connection) (*wshrpc } func (c S3Client) PutFile(ctx context.Context, conn *connparse.Connection, data wshrpc.FileData) error { - log.Printf("PutFile: %v", conn.GetFullURI()) if data.At != nil { log.Printf("PutFile: offset %d and size %d", data.At.Offset, data.At.Size) return errors.Join(errors.ErrUnsupported, fmt.Errorf("file data offset and size not supported")) diff --git a/pkg/wshrpc/wshremote/wshremote.go b/pkg/wshrpc/wshremote/wshremote.go index e737031277..da05953fce 100644 --- a/pkg/wshrpc/wshremote/wshremote.go +++ b/pkg/wshrpc/wshremote/wshremote.go @@ -126,13 +126,11 @@ func (impl *ServerImpl) remoteStreamFileDir(ctx context.Context, path string, by innerFileInfo := statToFileInfo(filepath.Join(path, innerFileInfoInt.Name()), innerFileInfoInt, false) fileInfoArr = append(fileInfoArr, innerFileInfo) if len(fileInfoArr) >= wshrpc.DirChunkSize { - logPrintfDev("sending %d entries\n", len(fileInfoArr)) dataCallback(fileInfoArr, nil, byteRange) fileInfoArr = nil } } if len(fileInfoArr) > 0 { - logPrintfDev("sending %d entries\n", len(fileInfoArr)) dataCallback(fileInfoArr, nil, byteRange) } return nil @@ -701,7 +699,6 @@ func (impl *ServerImpl) RemoteFileTouchCommand(ctx context.Context, path string) } func (impl *ServerImpl) RemoteFileMoveCommand(ctx context.Context, data wshrpc.CommandFileCopyData) error { - logPrintfDev("RemoteFileCopyCommand: src=%s, dest=%s\n", data.SrcUri, data.DestUri) opts := data.Opts destUri := data.DestUri srcUri := data.SrcUri @@ -827,7 +824,6 @@ func (*ServerImpl) RemoteWriteFileCommand(ctx context.Context, data wshrpc.FileD if err != nil { return fmt.Errorf("cannot write to file %q: %w", path, err) } - logPrintfDev("wrote %d bytes to file %q at offset %d\n", n, path, atOffset) return nil } @@ -872,9 +868,3 @@ func (*ServerImpl) DisposeSuggestionsCommand(ctx context.Context, widgetId strin suggestion.DisposeSuggestions(ctx, widgetId) return nil } - -func logPrintfDev(format string, args ...interface{}) { - if wavebase.IsDevMode() { - log.Printf(format, args...) - } -}