resolvedPath, err := ResolveUserPath(cc, requestedPath[len(cc.FileRoot())+1:])
if err != nil {
- return cc.NewErrReply(t, "Cannot upload to non-existent user folder.")
+ return cc.NewErrReply(t, "Cannot delete non-existent file.")
}
updateTransactionPath(t, resolvedPath)
- return HandleUploadFolder(cc, t)
+ return HandleDeleteFile(cc, t)
+}
+
+func HandleDownloadFileWithUserFolders(cc *hotline.ClientConn, t *hotline.Transaction) (res []hotline.Transaction) {
+ requestedPath, err := hotline.ReadPath(cc.FileRoot(), t.GetField(hotline.FieldFilePath).Data, nil)
+ if err != nil {
+ return res
+ }
+
+ resolvedPath, err := ResolveUserPath(cc, requestedPath[len(cc.FileRoot())+1:])
+ if err != nil {
+ return cc.NewErrReply(t, "Cannot download non-existent user file.")
+ }
+
+ updateTransactionPath(t, resolvedPath)
+ return HandleDownloadFile(cc, t)
+}
+
+func HandleDownloadFolderWithUserFolders(cc *hotline.ClientConn, t *hotline.Transaction) (res []hotline.Transaction) {
+ requestedPath, err := hotline.ReadPath(cc.FileRoot(), t.GetField(hotline.FieldFilePath).Data, nil)
+ if err != nil {
+ return res
+ }
+
+ resolvedPath, err := ResolveUserPath(cc, requestedPath[len(cc.FileRoot())+1:])
+ if err != nil {
+ return cc.NewErrReply(t, "Cannot download non-existent user folder.")
+ }
+
+ updateTransactionPath(t, resolvedPath)
+ return HandleDownloadFolder(cc, t)
}
srv.HandleFunc(hotline.TranDeleteFile, HandleDeleteFileWithUserFolders)
srv.HandleFunc(hotline.TranDeleteUser, HandleDeleteUser)
srv.HandleFunc(hotline.TranDisconnectUser, HandleDisconnectUser)
- srv.HandleFunc(hotline.TranDownloadFile, HandleDownloadFile)
- srv.HandleFunc(hotline.TranDownloadFldr, HandleDownloadFolder)
+ srv.HandleFunc(hotline.TranDownloadFile, HandleDownloadFileWithUserFolders)
+ srv.HandleFunc(hotline.TranDownloadFldr, HandleDownloadFolderWithUserFolders)
srv.HandleFunc(hotline.TranGetClientInfoText, HandleGetClientInfoText)
srv.HandleFunc(hotline.TranGetFileInfo, HandleGetFileInfo)
srv.HandleFunc(hotline.TranGetFileNameList, HandleGetFileNameListWithUserFolders)