diff --git a/CHANGELOG.md b/CHANGELOG.md index be7348f5..c5fac70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.11.0](https://github.com/filebrowser/filebrowser/compare/v2.10.0...v2.11.0) (2020-12-28) + + +### Features + +* add sharing management ([#1178](https://github.com/filebrowser/filebrowser/issues/1178)) (closes [#1000](https://github.com/filebrowser/filebrowser/issues/1000)) ([677bce3](https://github.com/filebrowser/filebrowser/commit/677bce376b024d9ff38f34e74243034fe5a1ec3c)) +* download shared subdirectory ([#1184](https://github.com/filebrowser/filebrowser/issues/1184)) ([fb5b28d](https://github.com/filebrowser/filebrowser/commit/fb5b28d9cbdee10d38fcd719b9fd832121be58ef)) + + +### Bug Fixes + +* check user input to prevent permission elevation ([#1196](https://github.com/filebrowser/filebrowser/issues/1196)) (closes [#1195](https://github.com/filebrowser/filebrowser/issues/1195)) ([f62806f](https://github.com/filebrowser/filebrowser/commit/f62806f6c9e9c7f392d1b747d65b8fe40b313e89)) +* delete extra remove prefix ([#1186](https://github.com/filebrowser/filebrowser/issues/1186)) ([7a5298a](https://github.com/filebrowser/filebrowser/commit/7a5298a7556f7dcc52f59b8ea76d040d3ddc3d12)) +* move files between different volumes (closes [#1177](https://github.com/filebrowser/filebrowser/issues/1177)) ([58835b7](https://github.com/filebrowser/filebrowser/commit/58835b7e535cc96e1c8a5d85821c1545743ca757)) +* recaptcha race condition ([#1176](https://github.com/filebrowser/filebrowser/issues/1176)) ([ac3673e](https://github.com/filebrowser/filebrowser/commit/ac3673e111afac6616af9650ca07028b6c27e6cd)) + ## [2.10.0](https://github.com/filebrowser/filebrowser/compare/v2.9.0...v2.10.0) (2020-11-24) diff --git a/fileutils/file.go b/fileutils/file.go index 5c0248df..6e6cd2af 100644 --- a/fileutils/file.go +++ b/fileutils/file.go @@ -9,6 +9,25 @@ import ( "github.com/spf13/afero" ) +// MoveFile moves file from src to dst. +// By default the rename filesystem system call is used. If src and dst point to different volumes +// the file copy is used as a fallback +func MoveFile(fs afero.Fs, src, dst string) error { + if fs.Rename(src, dst) == nil { + return nil + } + // fallback + err := CopyFile(fs, src, dst) + if err != nil { + _ = fs.Remove(dst) + return err + } + if err := fs.Remove(src); err != nil { + return err + } + return nil +} + // CopyFile copies a file from source to dest and returns // an error if any. func CopyFile(fs afero.Fs, source, dest string) error { @@ -39,14 +58,14 @@ func CopyFile(fs afero.Fs, source, dest string) error { return err } - // Copy the mode if the user can't - // open the file. + // Copy the mode info, err := fs.Stat(source) if err != nil { - err = fs.Chmod(dest, info.Mode()) - if err != nil { - return err - } + return err + } + err = fs.Chmod(dest, info.Mode()) + if err != nil { + return err } return nil diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 08f0d84a..d12a4237 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -58,7 +58,7 @@ export async function put (url, content = '') { } export function download (format, ...files) { - let url = `${baseURL}/api/raw` + let url = store.getters['isSharing'] ? `${baseURL}/api/public/dl/${store.state.hash}` : `${baseURL}/api/raw` if (files.length === 1) { url += removePrefix(files[0]) + '?' @@ -121,7 +121,7 @@ function moveCopy (items, copy = false, overwrite = false, rename = false) { let promises = [] for (let item of items) { - const from = removePrefix(item.from) + const from = item.from const to = encodeURIComponent(removePrefix(item.to)) const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}&override=${overwrite}&rename=${rename}` promises.push(resourceAction(url, 'PATCH')) diff --git a/frontend/src/api/share.js b/frontend/src/api/share.js index e14c4e81..6f8a2a17 100644 --- a/frontend/src/api/share.js +++ b/frontend/src/api/share.js @@ -1,5 +1,9 @@ import { fetchURL, fetchJSON, removePrefix } from './utils' +export async function list() { + return fetchJSON('/api/shares') +} + export async function getHash(hash) { return fetchJSON(`/api/public/share/${hash}`) } diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index 617e2258..68337d10 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -36,6 +36,8 @@ export async function fetchJSON (url, opts) { export function removePrefix (url) { if (url.startsWith('/files')) { url = url.slice(6) + } else if (store.getters['isSharing']) { + url = url.slice(7 + store.state.hash.length) } if (url === '') url = '/' diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue index b9278d10..6d9a1270 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -8,8 +8,8 @@
-