aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-02-04 11:08:37 +0100
committerRubén Beltrán del Río <jj@r.bdr.sh>2026-09-29 21:30:10 +0200
commit3c48bc8ddd3dda2f96108c372c9be7737f491a77 (patch)
tree0b1aa2bf187ac67d051ea43bb60d51a817130ae9 /internal
parentdb123db4e16eea60584dddf8f3954c497ac50c89 (diff)
Add downloads as well
Diffstat (limited to 'internal')
-rw-r--r--internal/mobius/friendship_quest_file_extensions.go34
-rw-r--r--internal/mobius/transaction_handlers.go4
2 files changed, 34 insertions, 4 deletions
diff --git a/internal/mobius/friendship_quest_file_extensions.go b/internal/mobius/friendship_quest_file_extensions.go
index 1ef8ad6..f04868c 100644
--- a/internal/mobius/friendship_quest_file_extensions.go
+++ b/internal/mobius/friendship_quest_file_extensions.go
@@ -165,9 +165,39 @@ func HandleDeleteFileWithUserFolders(cc *hotline.ClientConn, t *hotline.Transact
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)
}
diff --git a/internal/mobius/transaction_handlers.go b/internal/mobius/transaction_handlers.go
index 91da59f..0a64fba 100644
--- a/internal/mobius/transaction_handlers.go
+++ b/internal/mobius/transaction_handlers.go
@@ -13,8 +13,8 @@ func RegisterHandlers(srv *hotline.Server) {
srv.HandleFunc(hotline.TranDeleteFile, /*STARTFQ*/HandleDeleteFileWithUserFolders/*ENDFQ*/)
srv.HandleFunc(hotline.TranDeleteUser, HandleDeleteUser)
srv.HandleFunc(hotline.TranDisconnectUser, HandleDisconnectUser)
- srv.HandleFunc(hotline.TranDownloadFile, HandleDownloadFile)
- srv.HandleFunc(hotline.TranDownloadFldr, HandleDownloadFolder)
+ srv.HandleFunc(hotline.TranDownloadFile, /*STARTFQ*/HandleDownloadFileWithUserFolders/*ENDFQ*/)
+ srv.HandleFunc(hotline.TranDownloadFldr, /*STARTFQ*/HandleDownloadFolderWithUserFolders/*ENDFQ*/)
srv.HandleFunc(hotline.TranGetClientInfoText, HandleGetClientInfoText)
srv.HandleFunc(hotline.TranGetFileInfo, HandleGetFileInfo)
srv.HandleFunc(hotline.TranGetFileNameList, /*STARTFQ*/HandleGetFileNameListWithUserFolders/*ENDFQ*/)