aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hotline/file_transfer.go2
-rw-r--r--internal/mobius/friendship_quest_file_extensions.go15
-rw-r--r--internal/mobius/handlers_files.go13
-rw-r--r--internal/mobius/handlers_transfers.go6
-rw-r--r--internal/mobius/transaction_handlers.go2
5 files changed, 33 insertions, 5 deletions
diff --git a/hotline/file_transfer.go b/hotline/file_transfer.go
index d0ce597..37825c9 100644
--- a/hotline/file_transfer.go
+++ b/hotline/file_transfer.go
@@ -310,7 +310,7 @@ func UploadHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileTransfe
// handler should have returned an error to the client indicating there was an existing file present.
_, err := fileStore.Stat(fullPath)
if err == nil {
- return fmt.Errorf("existing file found: %s", fullPath)
+ // return fmt.Errorf("existing file found: %s", fullPath)
}
if !errors.Is(err, fs.ErrNotExist) {
diff --git a/internal/mobius/friendship_quest_file_extensions.go b/internal/mobius/friendship_quest_file_extensions.go
index fb23b79..1ef8ad6 100644
--- a/internal/mobius/friendship_quest_file_extensions.go
+++ b/internal/mobius/friendship_quest_file_extensions.go
@@ -156,3 +156,18 @@ func HandleUploadFolderWithUserFolders(cc *hotline.ClientConn, t *hotline.Transa
updateTransactionPath(t, resolvedPath)
return HandleUploadFolder(cc, t)
}
+
+func HandleDeleteFileWithUserFolders(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 upload to non-existent user folder.")
+ }
+
+ updateTransactionPath(t, resolvedPath)
+ return HandleUploadFolder(cc, t)
+}
diff --git a/internal/mobius/handlers_files.go b/internal/mobius/handlers_files.go
index cbdf61e..0c7d5bb 100644
--- a/internal/mobius/handlers_files.go
+++ b/internal/mobius/handlers_files.go
@@ -195,6 +195,15 @@ func HandleDeleteFile(cc *hotline.ClientConn, t *hotline.Transaction) (res []hot
fileName := t.GetField(hotline.FieldFileName).Data
filePath := t.GetField(hotline.FieldFilePath).Data
+ /*STARTFQ*/
+ var fp hotline.FilePath
+ if filePath != nil {
+ if _, err := fp.Write(filePath); err != nil {
+ return res
+ }
+ }
+ /*ENDFQ*/
+
fullFilePath, err := hotline.ReadPath(cc.FileRoot(), filePath, fileName, cc.TextDecoder())
if err != nil {
cc.Logger.Error("delete file: read path", "err", err)
@@ -214,11 +223,11 @@ func HandleDeleteFile(cc *hotline.ClientConn, t *hotline.Transaction) (res []hot
switch mode := fi.Mode(); {
case mode.IsDir():
- if !cc.Authorize(hotline.AccessDeleteFolder) {
+ if !cc.Authorize(hotline.AccessDeleteFolder) /*STARTFQ*/ && !fp.IsUserDir() /*ENDFQ*/ {
return cc.NewErrReply(t, ErrMsgNotAllowedDeleteFolders)
}
case mode.IsRegular():
- if !cc.Authorize(hotline.AccessDeleteFile) {
+ if !cc.Authorize(hotline.AccessDeleteFile) /*STARTFQ*/ && !fp.IsUserDir() /*ENDFQ*/ {
return cc.NewErrReply(t, ErrMsgNotAllowedDeleteFiles)
}
}
diff --git a/internal/mobius/handlers_transfers.go b/internal/mobius/handlers_transfers.go
index 67c484b..93ec074 100644
--- a/internal/mobius/handlers_transfers.go
+++ b/internal/mobius/handlers_transfers.go
@@ -235,7 +235,11 @@ func HandleUploadFile(cc *hotline.ClientConn, t *hotline.Transaction) (res []hot
}
if _, err := cc.Server.FS.Stat(fullFilePath); err == nil {
- return cc.NewErrReply(t, fmt.Sprintf(ErrMsgFileUploadConflictTemplate, string(fileName)))
+ /*STARTFQ*/
+ if !fp.IsUserDir() {
+ return cc.NewErrReply(t, fmt.Sprintf(ErrMsgFileUploadConflictTemplate, string(fileName)))
+ }
+ /*ENDFQ*/
}
ft := cc.NewFileTransfer(hotline.FileUpload, cc.FileRoot(), fileName, filePath, transferSize)
diff --git a/internal/mobius/transaction_handlers.go b/internal/mobius/transaction_handlers.go
index f7e8760..91da59f 100644
--- a/internal/mobius/transaction_handlers.go
+++ b/internal/mobius/transaction_handlers.go
@@ -10,7 +10,7 @@ func RegisterHandlers(srv *hotline.Server) {
srv.HandleFunc(hotline.TranChatSend, HandleChatSend)
srv.HandleFunc(hotline.TranDelNewsArt, HandleDelNewsArt)
srv.HandleFunc(hotline.TranDelNewsItem, HandleDelNewsItem)
- srv.HandleFunc(hotline.TranDeleteFile, HandleDeleteFile)
+ srv.HandleFunc(hotline.TranDeleteFile, /*STARTFQ*/HandleDeleteFileWithUserFolders/*ENDFQ*/)
srv.HandleFunc(hotline.TranDeleteUser, HandleDeleteUser)
srv.HandleFunc(hotline.TranDisconnectUser, HandleDisconnectUser)
srv.HandleFunc(hotline.TranDownloadFile, HandleDownloadFile)