web client: add share mode read/write

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-05-09 19:09:43 +02:00
parent e72bb1e124
commit 1e0b3a2a8c
22 changed files with 457 additions and 108 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"mime"
"net/http"
"net/url"
@@ -79,10 +80,10 @@ func getRespStatus(err error) int {
if _, ok := err.(*util.RecordNotFoundError); ok {
return http.StatusNotFound
}
if os.IsNotExist(err) {
if errors.Is(err, fs.ErrNotExist) {
return http.StatusBadRequest
}
if os.IsPermission(err) || errors.Is(err, dataprovider.ErrLoginNotAllowedFromIP) {
if errors.Is(err, fs.ErrPermission) || errors.Is(err, dataprovider.ErrLoginNotAllowedFromIP) {
return http.StatusForbidden
}
if errors.Is(err, plugin.ErrNoSearcher) || errors.Is(err, dataprovider.ErrNotImplemented) {
@@ -241,7 +242,11 @@ func addZipEntry(wr *zip.Writer, conn *Connection, entryPath, baseDir string) er
return err
}
if info.IsDir() {
_, err := wr.Create(getZipEntryName(entryPath, baseDir) + "/")
_, err := wr.CreateHeader(&zip.FileHeader{
Name: getZipEntryName(entryPath, baseDir) + "/",
Method: zip.Deflate,
Modified: info.ModTime(),
})
if err != nil {
conn.Log(logger.LevelDebug, "unable to create zip entry %#v: %v", entryPath, err)
return err
@@ -271,7 +276,11 @@ func addZipEntry(wr *zip.Writer, conn *Connection, entryPath, baseDir string) er
}
defer reader.Close()
f, err := wr.Create(getZipEntryName(entryPath, baseDir))
f, err := wr.CreateHeader(&zip.FileHeader{
Name: getZipEntryName(entryPath, baseDir),
Method: zip.Deflate,
Modified: info.ModTime(),
})
if err != nil {
conn.Log(logger.LevelDebug, "unable to create zip entry %#v: %v", entryPath, err)
return err