"encoding/binary"
"errors"
"fmt"
- "github.com/davecgh/go-spew/spew"
"gopkg.in/yaml.v3"
"io/ioutil"
"math/big"
"os"
"path"
+ "path/filepath"
"sort"
"strings"
"time"
}
}
- hlFile.ffo.FlatFileInformationFork.setComment(t.GetField(fieldFileComment).Data)
+ if err := hlFile.ffo.FlatFileInformationFork.setComment(t.GetField(fieldFileComment).Data); err != nil {
+ return res, err
+ }
w, err := hlFile.infoForkWriter()
if err != nil {
return res, err
return res, err
}
- cc.Server.Logger.Debugw("Move file", "src", filePath+"/"+fileName, "dst", fileNewPath+"/"+fileName)
+ cc.logger.Infow("Move file", "src", filePath+"/"+fileName, "dst", fileNewPath+"/"+fileName)
hlFile, err := newFileWrapper(cc.Server.FS, filePath, 0)
+ if err != nil {
+ return res, err
+ }
fi, err := hlFile.dataFile()
if err != nil {
res = append(res, cc.NewErrReply(t, "You are not allowed to create folders."))
return res, err
}
- newFolderPath := cc.Server.Config.FileRoot
folderName := string(t.GetField(fieldFileName).Data)
folderName = path.Join("/", folderName)
+ var subPath string
+
// fieldFilePath is only present for nested paths
if t.GetField(fieldFilePath).Data != nil {
var newFp FilePath
if err != nil {
return nil, err
}
- newFolderPath += newFp.String()
+
+ for _, pathItem := range newFp.Items {
+ subPath = filepath.Join("/", subPath, string(pathItem.Name))
+ }
}
- newFolderPath = path.Join(newFolderPath, folderName)
+ newFolderPath := path.Join(cc.Server.Config.FileRoot, subPath, folderName)
// TODO: check path and folder name lengths
if len(subFields) == 1 {
login := DecodeUserString(getField(fieldData, &subFields).Data)
- cc.Server.Logger.Infow("DeleteUser", "login", login)
+ cc.logger.Infow("DeleteUser", "login", login)
if !authorize(cc.Account.Access, accessDeleteUser) {
res = append(res, cc.NewErrReply(t, "You are not allowed to delete accounts."))
// check if the login dataFile; if so, we know we are updating an existing user
if acc, ok := cc.Server.Accounts[login]; ok {
- cc.Server.Logger.Infow("UpdateUser", "login", login)
+ cc.logger.Infow("UpdateUser", "login", login)
// account dataFile, so this is an update action
if !authorize(cc.Account.Access, accessModifyUser) {
return res, err
}
} else {
- cc.Server.Logger.Infow("CreateUser", "login", login)
+ cc.logger.Infow("CreateUser", "login", login)
if !authorize(cc.Account.Access, accessCreateUser) {
res = append(res, cc.NewErrReply(t, "You are not allowed to create new accounts."))
cc.UserName = t.GetField(fieldUserName).Data
*cc.Icon = t.GetField(fieldUserIconID).Data
+ cc.logger = cc.logger.With("name", string(cc.UserName))
+
options := t.GetField(fieldOptions).Data
optBitmap := big.NewInt(int64(binary.BigEndian.Uint16(options)))
return res, err
}
- newsPath := t.GetField(fieldNewsPath).Data
- cc.Server.Logger.Infow("NewsPath: ", "np", string(newsPath))
-
pathStrs := ReadNewsPath(t.GetField(fieldNewsPath).Data)
cats := cc.Server.GetNewsCatByPath(pathStrs)
name := string(t.GetField(fieldFileName).Data)
pathStrs := ReadNewsPath(t.GetField(fieldNewsPath).Data)
- cc.Server.Logger.Infof("Creating new news folder %s", name)
+ cc.logger.Infof("Creating new news folder %s", name)
cats := cc.Server.GetNewsCatByPath(pathStrs)
cats[name] = NewsCategoryListData15{
// TODO: determine if path is a Folder (Bundle) or Category and check for permission
- cc.Server.Logger.Infof("DelNewsItem %v", pathStrs)
+ cc.logger.Infof("DelNewsItem %v", pathStrs)
cats := cc.Server.ThreadedNews.Categories
return res, err
}
- spew.Dump(fullPath)
-
var fp FilePath
if t.GetField(fieldFilePath).Data != nil {
if err = fp.UnmarshalBinary(t.GetField(fieldFilePath).Data); err != nil {
// Handle special case for drop box folders
if fp.IsDropbox() && !authorize(cc.Account.Access, accessViewDropBoxes) {
- res = append(res, cc.NewReply(t))
+ res = append(res, cc.NewErrReply(t, "You are not allowed to view drop boxes."))
return res, err
}
return res, err
}
- cc.Server.Logger.Debugw("Make alias", "src", fullFilePath, "dst", fullNewFilePath)
+ cc.logger.Debugw("Make alias", "src", fullFilePath, "dst", fullNewFilePath)
if err := cc.Server.FS.Symlink(fullFilePath, fullNewFilePath); err != nil {
res = append(res, cc.NewErrReply(t, "Error creating alias"))