Compare commits

...
50 changed files with 473 additions and 328 deletions

No files matched your search

+10 -10
View File
@@ -87,16 +87,16 @@ jobs:
echo "✅ Successfully merged '$BETA_BRANCH' into '$STABLE_BRANCH'."
- name: Delete beta branch after successful merge
run: |
VERSION="${{ github.event.inputs.version }}"
BETA_BRANCH="beta/v$VERSION"
# Delete beta branch locally and remotely
git branch -d "$BETA_BRANCH"
git push origin --delete "$BETA_BRANCH"
echo "✅ Successfully deleted '$BETA_BRANCH'."
# - name: Delete beta branch after successful merge
# run: |
# VERSION="${{ github.event.inputs.version }}"
# BETA_BRANCH="beta/v$VERSION"
#
# # Delete beta branch locally and remotely
# git branch -d "$BETA_BRANCH"
# git push origin --delete "$BETA_BRANCH"
#
# echo "✅ Successfully deleted '$BETA_BRANCH'."
- name: Create Pull Request to Main
uses: peter-evans/create-pull-request@v6
+10 -10
View File
@@ -87,13 +87,13 @@ jobs:
echo "✅ Successfully merged '$DEV_BRANCH' into '$BETA_BRANCH'."
- name: Delete dev branch after successful merge
run: |
VERSION="${{ github.event.inputs.version }}"
DEV_BRANCH="dev/v$VERSION"
# Delete dev branch locally and remotely
git branch -d "$DEV_BRANCH"
git push origin --delete "$DEV_BRANCH"
echo "✅ Successfully deleted '$DEV_BRANCH'."
# - name: Delete dev branch after successful merge
# run: |
# VERSION="${{ github.event.inputs.version }}"
# DEV_BRANCH="dev/v$VERSION"
#
# # Delete dev branch locally and remotely
# git branch -d "$DEV_BRANCH"
# git push origin --delete "$DEV_BRANCH"
#
# echo "✅ Successfully deleted '$DEV_BRANCH'."
+28
View File
@@ -2,6 +2,34 @@
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
## v0.6.5-beta
**Notes**:
- added more share and download tests
**BugFixes**:
- fix share download issue https://github.com/gtsteffaniak/filebrowser/issues/465
- fix content length size calculation issue when downloading multiple files.
## v0.6.4-beta
**BugFixes**:
- fix preview arow issue. https://github.com/gtsteffaniak/filebrowser/issues/457
- fix password change issue.
- apply user defaults to publi user on startup https://github.com/gtsteffaniak/filebrowser/issues/451
## v0.6.3-beta
**Notes**:
- windows directories get better naming, root directories like "D:\ get named "D", otherwise base filepath is the name when unselected "D:\path\to\folder" gets named "folder" (just like linux)
- `.pdf` files added to default onlyoffice exclusion list.
**BugFixes**:
- windows would not refresh file info automatically when viewing because of path issue.
- windows paths without name for "D:\" would cause issues.
- share path error https://github.com/gtsteffaniak/filebrowser/issues/429
- fix bug where resource content flag would load entire file into memory.
## v0.6.2-beta
**Notes**:
+3
View File
@@ -19,6 +19,9 @@
> [!WARNING]
> There is no stable version -- planned 2025.
> [!NOTE]
> [Read about upcoming 0.7.0 release](https://github.com/gtsteffaniak/filebrowser/discussions/459)
FileBrowser Quantum is a fork of the file browser open-source project with the following changes:
1. ✅ Indexes files (See [indexing Wiki](https://github.com/gtsteffaniak/filebrowser/wiki/Indexing) for more info.)
@@ -10,9 +10,9 @@ import { defineConfig, devices } from "@playwright/test";
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
globalSetup: "./global-setup",
globalSetup: "./tests-playwright/global-setup",
timeout: 5000,
testDir: "./tests",
testDir: "./tests-playwright/general",
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -12,7 +12,7 @@ import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
//globalSetup: "./global-setup",
timeout: 5000,
testDir: "./tests-noauth",
testDir: "./tests-playwright/noauth",
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -12,7 +12,7 @@ import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
//globalSetup: "./global-setup",
timeout: 3000,
testDir: "./tests-proxy",
testDir: "./tests-playwright/proxy",
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
+7
View File
@@ -15,6 +15,13 @@ func validateUserInfo() {
logger.Fatal(fmt.Sprintf("could not load users: %v", err))
}
for _, user := range usersList {
if user.Username == "publicUser" {
settings.ApplyUserDefaults(user)
err := store.Users.Save(user, false)
if err != nil {
logger.Error(fmt.Sprintf("could not update user: %v", err))
}
}
updateUserScopes(user)
}
}
+6 -2
View File
@@ -82,7 +82,6 @@ func FileInfoFaster(opts FileOptions) (ExtendedFileInfo, error) {
if index == nil {
return response, fmt.Errorf("could not get index: %v ", opts.Source)
}
realPath, isDir, err := index.GetRealPath(opts.Path)
if err != nil {
return response, err
@@ -115,7 +114,12 @@ func FileInfoFaster(opts FileOptions) (ExtendedFileInfo, error) {
if !exists {
return response, fmt.Errorf("could not get metadata for path: %v", opts.Path)
}
if opts.Content {
if opts.Content && strings.HasPrefix(info.Type, "text") {
// Check file size
if info.Size > 50*1024*1024 { // 50 megabytes in bytes
logger.Debug(fmt.Sprintf("Reading large text file contents: "+info.Path, info.Name))
}
content, err := getContent(realPath)
if err != nil {
return response, err
-2
View File
@@ -184,10 +184,8 @@ func (idx *Index) indexDirectory(adjustedPath string, quick, recursive bool) err
}
dirFileInfo.SortItems()
// Update the current directory metadata in the index
idx.UpdateMetadata(dirFileInfo)
return nil
}
-1
View File
@@ -13,7 +13,6 @@ import (
// todo fix this!!
// MakeUserDir makes the user directory according to settings.
func MakeUserDir(fullPath string) error {
logger.Debug(fmt.Sprintf("creating user home dir: [%s]", fullPath))
if err := os.MkdirAll(fullPath, os.ModePerm); err != nil {
return err
}
+14 -14
View File
@@ -1,24 +1,24 @@
module github.com/gtsteffaniak/filebrowser/backend
go 1.23
go 1.23.0
toolchain go1.23.1
toolchain go1.24.1
require (
github.com/asdine/storm/v3 v3.2.1
github.com/disintegration/imaging v1.6.2
github.com/dsoprea/go-exif/v3 v3.0.1
github.com/goccy/go-yaml v1.15.23
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/google/go-cmp v0.6.0
github.com/goccy/go-yaml v1.16.0
github.com/golang-jwt/jwt/v4 v4.5.2
github.com/google/go-cmp v0.7.0
github.com/shirou/gopsutil/v3 v3.24.5
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.10.0
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.16.4
golang.org/x/crypto v0.33.0
golang.org/x/image v0.24.0
golang.org/x/sys v0.30.0
golang.org/x/crypto v0.36.0
golang.org/x/image v0.25.0
golang.org/x/sys v0.31.0
)
require (
@@ -28,11 +28,11 @@ require (
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/golang/geo v0.0.0-20250321002858-2bb09a976f49 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
@@ -41,9 +41,9 @@ require (
github.com/swaggo/files v1.0.1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.etcd.io/bbolt v1.4.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.30.0 // indirect
golang.org/x/net v0.37.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/tools v0.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+28 -28
View File
@@ -36,23 +36,23 @@ github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3Bop
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic=
github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/goccy/go-yaml v1.15.23 h1:WS0GAX1uNPDLUvLkNU2vXq6oTnsmfVFocjQ/4qA48qo=
github.com/goccy/go-yaml v1.15.23/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
github.com/goccy/go-yaml v1.16.0 h1:d7m1G7A0t+logajVtklHfDYJs2Et9g3gHwdBNNFou0w=
github.com/goccy/go-yaml v1.16.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U=
github.com/golang/geo v0.0.0-20250321002858-2bb09a976f49 h1:JJ32MDIC/hIQ/Fq8Ej9Hgh1s3D82FYNMt54WYViOI7Y=
github.com/golang/geo v0.0.0-20250321002858-2bb09a976f49/go.mod h1:J+F9/3Ofc8ysEOY2/cNjxTMl2eB1gvPIywEHUplPgDA=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
@@ -60,8 +60,8 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -104,14 +104,14 @@ go.etcd.io/bbolt v1.4.0 h1:TU77id3TnN/zKr7CO/uk+fBCwF2jGcMuw2B/FMAzYIk=
go.etcd.io/bbolt v1.4.0/go.mod h1:AsD+OCi/qPN1giOX1aiLAha3o1U8rAz65bvN4j0sRuk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191105084925-a882066a44e0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -123,12 +123,12 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -143,8 +143,8 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@@ -153,13 +153,13 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
+2 -2
View File
@@ -56,8 +56,8 @@ func withHashFileHelper(fn handleFunc) handleFunc {
return status, fmt.Errorf("could not authenticate share request")
}
}
data.path = strings.TrimSuffix(link.Path, "/") + "/" + strings.TrimPrefix(path, "/")
// Get file information with options
file, err := FileInfoFasterFunc(files.FileOptions{
Path: data.path,
@@ -67,11 +67,11 @@ func withHashFileHelper(fn handleFunc) handleFunc {
})
file.Token = link.Token
if err != nil {
logger.Error(fmt.Sprintf("error fetching file info for share %v %v %v", hash, path, err))
return errToStatus(err), fmt.Errorf("error fetching share from server")
}
// Set the file info in the `data` object
data.raw = file
// Call the next handler with the data
return fn(w, r, data)
}
+2 -2
View File
@@ -7,7 +7,6 @@ import (
"io"
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"
@@ -16,6 +15,7 @@ import (
"github.com/gtsteffaniak/filebrowser/backend/files"
"github.com/gtsteffaniak/filebrowser/backend/logger"
"github.com/gtsteffaniak/filebrowser/backend/settings"
"github.com/gtsteffaniak/filebrowser/backend/utils"
)
const (
@@ -63,7 +63,7 @@ func onlyofficeClientConfigGetHandler(w http.ResponseWriter, r *http.Request, d
return http.StatusForbidden, err
}
fileInfo, err := files.FileInfoFaster(files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Modify: d.user.Perm.Modify,
Source: source,
Expand: false,
+2 -1
View File
@@ -15,6 +15,7 @@ import (
"github.com/gtsteffaniak/filebrowser/backend/img"
"github.com/gtsteffaniak/filebrowser/backend/logger"
"github.com/gtsteffaniak/filebrowser/backend/settings"
"github.com/gtsteffaniak/filebrowser/backend/utils"
)
type ImgService interface {
@@ -61,7 +62,7 @@ func previewHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (
return http.StatusForbidden, err
}
fileInfo, err := files.FileInfoFaster(files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Modify: d.user.Perm.Modify,
Source: source,
Expand: true,
+11 -10
View File
@@ -29,20 +29,21 @@ import (
// @Failure 500 {object} map[string]string "Internal server error"
// @Router /public/dl [get]
func publicRawHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
filePrefix := ""
file, ok := d.raw.(files.ExtendedFileInfo)
if ok {
filePrefix = file.Source + "::"
}
encodedFiles := file.Path + r.URL.Query().Get("files")
encodedFiles := r.URL.Query().Get("files")
// Decode the URL-encoded path
files, err := url.QueryUnescape(encodedFiles)
f, err := url.QueryUnescape(encodedFiles)
if err != nil {
return http.StatusBadRequest, fmt.Errorf("invalid path encoding: %v", err)
}
fileList := strings.Split(files, "||")
for i, f := range fileList {
fileList[i] = filePrefix + f
fileInfo, ok := d.raw.(files.ExtendedFileInfo)
if !ok {
return http.StatusInternalServerError, fmt.Errorf("failed to assert type files.FileInfo")
}
prefix := fileInfo.Path
fileList := []string{}
for _, file := range strings.Split(f, "||") {
fileList = append(fileList, fileInfo.Source+"::"+prefix+file)
}
return rawFilesHandler(w, r, d, fileList)
}
+61 -65
View File
@@ -3,6 +3,7 @@ package http
import (
"archive/tar"
"archive/zip"
"bytes"
"compress/gzip"
"errors"
"fmt"
@@ -43,11 +44,6 @@ func setContentDisposition(w http.ResponseWriter, r *http.Request, fileName stri
// @Failure 500 {object} map[string]string "Internal server error"
// @Router /api/raw [get]
func rawHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
filePrefix := ""
file, ok := d.raw.(files.ExtendedFileInfo)
if ok {
filePrefix = file.Path
}
encodedFiles := r.URL.Query().Get("files")
// Decode the URL-encoded path
files, err := url.QueryUnescape(encodedFiles)
@@ -55,9 +51,6 @@ func rawHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int,
return http.StatusBadRequest, fmt.Errorf("invalid path encoding: %v", err)
}
fileList := strings.Split(files, "||")
for i, f := range fileList {
fileList[i] = filepath.Join(filePrefix, f)
}
return rawFilesHandler(w, r, d, fileList)
}
@@ -68,9 +61,13 @@ func addFile(path string, d *requestContext, tarWriter *tar.Writer, zipWriter *z
}
source := splitFile[0]
path = splitFile[1]
userScope, err := settings.GetScopeFromSourceName(d.user.Scopes, source)
if d.share == nil && err != nil {
return fmt.Errorf("source %s is not available for user %s", source, d.user.Username)
var err error
userScope := "/"
if d.user.Username != "publicUser" {
userScope, err = settings.GetScopeFromSourceName(d.user.Scopes, source)
if d.share == nil && err != nil {
return fmt.Errorf("source %s is not available for user %s", source, d.user.Username)
}
}
idx := files.GetIndex(source)
@@ -192,9 +189,13 @@ func rawFilesHandler(w http.ResponseWriter, r *http.Request, d *requestContext,
firstFileSource := splitFile[0]
firstFilePath := splitFile[1]
fileName := filepath.Base(firstFilePath)
userscope, err := settings.GetScopeFromSourceName(d.user.Scopes, firstFileSource)
if err != nil && d.user.Username != "publicUser" {
return http.StatusForbidden, err
var err error
userscope := "/"
if d.user.Username != "publicUser" {
userscope, err = settings.GetScopeFromSourceName(d.user.Scopes, firstFileSource)
if err != nil {
return http.StatusForbidden, err
}
}
idx := files.GetIndex(firstFileSource)
if idx == nil {
@@ -205,14 +206,14 @@ func rawFilesHandler(w http.ResponseWriter, r *http.Request, d *requestContext,
return http.StatusInternalServerError, err
}
// Compute estimated download size
estimatedSize, err := computeArchiveSize(fileList, d)
if err != nil {
return http.StatusInternalServerError, err
}
// ** Single file download with Content-Length **
if len(fileList) == 1 && !isDir {
var estimatedSize int64
// Compute estimated download size
estimatedSize, err = computeArchiveSize(fileList, d)
if err != nil {
return http.StatusInternalServerError, err
}
fd, err2 := os.Open(realPath)
if err2 != nil {
return http.StatusInternalServerError, err2
@@ -255,7 +256,7 @@ func rawFilesHandler(w http.ResponseWriter, r *http.Request, d *requestContext,
return http.StatusInternalServerError, errors.New("format not implemented")
}
baseDirName := filepath.Base(filepath.Dir(realPath))
baseDirName := filepath.Base(filepath.Dir(firstFilePath))
if baseDirName == "" || baseDirName == "/" {
baseDirName = "download"
}
@@ -264,21 +265,29 @@ func rawFilesHandler(w http.ResponseWriter, r *http.Request, d *requestContext,
}
fileName = url.PathEscape(baseDirName + extension)
// Set headers for archive
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+fileName)
w.Header().Set("Content-Length", fmt.Sprintf("%d", estimatedSize))
var archiveData []byte
if extension == ".zip" {
archiveData, err = createZip(d, fileList...)
} else {
archiveData, err = createTarGz(d, fileList...)
}
if err != nil {
return http.StatusInternalServerError, err
}
sizeInMB := estimatedSize / 1024 / 1024
calculatedSize := len(archiveData)
sizeInMB := calculatedSize / 1024 / 1024
// if larger than 100 megabytes, log it
if sizeInMB > 100 {
logger.Debug(fmt.Sprintf("User %v is downloading large (%d MB) file: %v", d.user.Username, sizeInMB, fileName))
}
// Create archive and stream it
if extension == ".zip" {
err = createZip(w, d, fileList...)
} else {
err = createTarGz(w, d, fileList...)
}
// Set headers AFTER computing actual archive size
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+fileName)
w.Header().Set("Content-Length", fmt.Sprintf("%d", calculatedSize))
// Write archive data to response
_, err = w.Write(archiveData)
if err != nil {
return http.StatusInternalServerError, err
}
@@ -299,9 +308,13 @@ func computeArchiveSize(fileList []string, d *requestContext) (int64, error) {
if idx == nil {
return 0, fmt.Errorf("source %s is not available", source)
}
userScope, err := settings.GetScopeFromSourceName(d.user.Scopes, source)
if d.share == nil && err != nil {
return 0, fmt.Errorf("source %s is not available for user %s", source, d.user.Username)
var err error
userScope := "/"
if d.user.Username != "publicUser" {
userScope, err = settings.GetScopeFromSourceName(d.user.Scopes, source)
if d.share == nil && err != nil {
return 0, fmt.Errorf("source %s is not available for user %s", source, d.user.Username)
}
}
_, isDir, err := idx.GetRealPath(userScope, path)
if err != nil {
@@ -316,53 +329,36 @@ func computeArchiveSize(fileList []string, d *requestContext) (int64, error) {
return estimatedSize, nil
}
func createZip(w io.Writer, d *requestContext, filenames ...string) error {
zipWriter := zip.NewWriter(w)
defer zipWriter.Close()
// Stream the response to avoid high memory usage
if f, ok := w.(http.Flusher); ok {
f.Flush()
}
func createZip(d *requestContext, filenames ...string) ([]byte, error) {
var buf bytes.Buffer
zipWriter := zip.NewWriter(&buf)
// Check if we have exactly one directory
//flatten := len(filenames) == 1
for _, fname := range filenames {
err := addFile(fname, d, nil, zipWriter, false)
if err != nil {
logger.Error(fmt.Sprintf("Failed to add %s to ZIP: %v", fname, err))
return err
}
// Flush after adding each file
if f, ok := w.(http.Flusher); ok {
f.Flush()
return nil, err
}
}
return nil
zipWriter.Close()
return buf.Bytes(), nil
}
func createTarGz(w io.Writer, d *requestContext, filenames ...string) error {
gzWriter := gzip.NewWriter(w)
defer gzWriter.Close()
func createTarGz(d *requestContext, filenames ...string) ([]byte, error) {
var buf bytes.Buffer
gzWriter := gzip.NewWriter(&buf)
tarWriter := tar.NewWriter(gzWriter)
defer tarWriter.Close()
if f, ok := w.(http.Flusher); ok {
f.Flush()
}
// Check if we have exactly one directory
//flatten := len(filenames) == 1
for _, fname := range filenames {
err := addFile(fname, d, tarWriter, nil, false)
if err != nil {
logger.Error(fmt.Sprintf("Failed to add %s to TAR.GZ: %v", fname, err))
return err
}
if f, ok := w.(http.Flusher); ok {
f.Flush()
return nil, err
}
}
tarWriter.Close()
gzWriter.Close()
return nil
return buf.Bytes(), nil
}
+6 -4
View File
@@ -18,6 +18,7 @@ import (
"github.com/gtsteffaniak/filebrowser/backend/files"
"github.com/gtsteffaniak/filebrowser/backend/logger"
"github.com/gtsteffaniak/filebrowser/backend/settings"
"github.com/gtsteffaniak/filebrowser/backend/utils"
)
// resourceGetHandler retrieves information about a resource.
@@ -50,8 +51,9 @@ func resourceGetHandler(w http.ResponseWriter, r *http.Request, d *requestContex
if err != nil {
return http.StatusForbidden, err
}
fileInfo, err := files.FileInfoFaster(files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Modify: d.user.Perm.Modify,
Source: source,
Expand: true,
@@ -115,7 +117,7 @@ func resourceDeleteHandler(w http.ResponseWriter, r *http.Request, d *requestCon
return http.StatusForbidden, err
}
fileInfo, err := files.FileInfoFaster(files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Source: source,
Modify: d.user.Perm.Modify,
Expand: false,
@@ -172,7 +174,7 @@ func resourcePostHandler(w http.ResponseWriter, r *http.Request, d *requestConte
return http.StatusForbidden, err
}
fileOpts := files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Source: source,
Modify: d.user.Perm.Modify,
Expand: false,
@@ -246,7 +248,7 @@ func resourcePutHandler(w http.ResponseWriter, r *http.Request, d *requestContex
return http.StatusForbidden, err
}
fileOpts := files.FileOptions{
Path: filepath.Join(userscope, path),
Path: utils.JoinPathAsUnix(userscope, path),
Source: source,
Modify: d.user.Perm.Modify,
Expand: false,
+1 -1
View File
@@ -103,7 +103,7 @@ func StartHttp(ctx context.Context, Service ImgService, storage *storage.Storage
// Share routes
api.HandleFunc("GET /shares", withPermShare(shareListHandler))
api.HandleFunc("GET /share", withPermShare(shareGetsHandler))
api.HandleFunc("GET /share", withPermShare(shareGetHandler))
api.HandleFunc("POST /share", withPermShare(sharePostHandler))
api.HandleFunc("DELETE /share", withPermShare(shareDeleteHandler))
+1 -1
View File
@@ -21,7 +21,7 @@ type settingsData struct {
// @Tags Settings
// @Accept json
// @Produce json
// @Param property query string false "Property to retrieve"
// @Param property query string false "Property to retrieve: `userDefaults`, `frontend`, `auth`, `server`, `sources`"
// @Success 200 {object} settingsData "System settings data"
// @Router /api/settings [get]
func settingsGetHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
+1 -1
View File
@@ -64,7 +64,7 @@ func shareListHandler(w http.ResponseWriter, r *http.Request, d *requestContext)
// @Success 200 {array} share.Link "List of share links for the specified path"
// @Failure 500 {object} map[string]string "Internal server error"
// @Router /api/share [get]
func shareGetsHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
func shareGetHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
path := r.URL.Query().Get("path")
source := r.URL.Query().Get("source")
if source == "" {
+5 -3
View File
@@ -11,7 +11,6 @@ import (
yaml "github.com/goccy/go-yaml"
"github.com/gtsteffaniak/filebrowser/backend/logger"
"github.com/gtsteffaniak/filebrowser/backend/users"
"github.com/gtsteffaniak/filebrowser/backend/utils"
"github.com/gtsteffaniak/filebrowser/backend/version"
)
@@ -61,7 +60,10 @@ func setupSources() {
} else {
for k, source := range Config.Server.Sources {
realPath := getRealPath(source.Path)
name := utils.GetLastComponent(realPath)
name := filepath.Base(realPath)
if name == "\\" {
name = strings.Split(realPath, ":")[0]
}
source.Path = realPath // use absolute path
if source.Name == "" {
_, ok := Config.Server.SourceMap[source.Path]
@@ -223,7 +225,7 @@ func setDefaults() Settings {
Name: "FileBrowser Quantum",
},
UserDefaults: UserDefaults{
DisableOnlyOfficeExt: ".txt .csv .html",
DisableOnlyOfficeExt: ".txt .csv .html .pdf",
StickySidebar: true,
LockPassword: false,
ShowHidden: false,
+26 -20
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"reflect"
"slices"
"strings"
storm "github.com/asdine/storm/v3"
@@ -72,6 +73,10 @@ func (st usersBackend) Update(user *users.User, actorIsAdmin bool, fields ...str
return err
}
if !slices.Contains(fields, "Password") {
user.Password = existingUser.Password
}
if !actorIsAdmin {
err := checkRestrictedFields(existingUser, fields)
if err != nil {
@@ -109,7 +114,7 @@ func (st usersBackend) Update(user *users.User, actorIsAdmin bool, fields ...str
// Get the value to be stored
val := fieldValue.Interface()
// Update the database
if err := st.db.UpdateField(user, field, val); err != nil {
if err := st.db.UpdateField(existingUser, field, val); err != nil {
return fmt.Errorf("failed to update user field: %s, error: %v", field, err)
}
}
@@ -193,34 +198,35 @@ func parseFields(user *users.User, fields []string) ([]string, error) {
// Dynamically populate fields to update
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
if (field.Name == "password" && user.Password != "") || field.Name != "password" {
// which=all can't update password
if strings.ToLower(field.Name) != "password" && strings.ToLower(field.Name) != "id" && strings.ToLower(field.Name) != "username" {
fields = append(fields, field.Name)
}
}
}
newfields := []string{}
for _, field := range fields {
newfields = append(newfields, utils.CapitalizeFirst(field))
}
if slices.Contains(newfields, "Password") && user.Password != "" {
if settings.Config.Auth.Methods.PasswordAuth.Enabled {
pass, err := users.HashPwd(user.Password)
if err != nil {
return newfields, err
capitalField := utils.CapitalizeFirst(field)
if capitalField == "Scopes" {
newScopes, err := settings.ConvertToBackendScopes(user.Scopes)
if err == nil {
user.Scopes = newScopes
}
err = files.MakeUserDirs(user)
if err != nil {
logger.Error(err.Error())
}
user.Password = pass
}
}
if slices.Contains(newfields, "Scopes") {
newScopes, err := settings.ConvertToBackendScopes(user.Scopes)
if err == nil {
user.Scopes = newScopes
}
err = files.MakeUserDirs(user)
if err != nil {
logger.Error(err.Error())
}
if capitalField == "Password" {
value, err := users.HashPwd(user.Password)
if err != nil {
logger.Error(err.Error())
}
user.Password = value
}
newfields = append(newfields, capitalField)
}
return newfields, nil
}
+1 -1
View File
@@ -904,7 +904,7 @@ const docTemplate = `{
"parameters": [
{
"type": "string",
"description": "Property to retrieve",
"description": "Property to retrieve: ` + "`" + `userDefaults` + "`" + `, ` + "`" + `frontend` + "`" + `, ` + "`" + `auth` + "`" + `, ` + "`" + `server` + "`" + `, ` + "`" + `sources` + "`" + `",
"name": "property",
"in": "query"
}
+1 -1
View File
@@ -893,7 +893,7 @@
"parameters": [
{
"type": "string",
"description": "Property to retrieve",
"description": "Property to retrieve: `userDefaults`, `frontend`, `auth`, `server`, `sources`",
"name": "property",
"in": "query"
}
+2 -1
View File
@@ -887,7 +887,8 @@ paths:
description: Returns the current configuration settings for signup, user directories,
rules, frontend.
parameters:
- description: Property to retrieve
- description: 'Property to retrieve: `userDefaults`, `frontend`, `auth`, `server`,
`sources`'
in: query
name: property
type: string
+10
View File
@@ -6,7 +6,9 @@ import (
"encoding/hex"
"fmt"
math "math/rand"
"path/filepath"
"reflect"
"runtime"
"strings"
"time"
@@ -104,3 +106,11 @@ func GetLastComponent(path string) string {
}
return path[lastSlash+1:]
}
func JoinPathAsUnix(parts ...string) string {
joinedPath := filepath.Join(parts...)
if runtime.GOOS == "windows" {
joinedPath = strings.ReplaceAll(joinedPath, "\\", "/")
}
return joinedPath
}
+2 -3
View File
@@ -1,5 +1,5 @@
import { adjustedData } from "./utils";
import { getApiPath, removePrefix, extractSourceFromPath } from "@/utils/url.js";
import { getApiPath, extractSourceFromPath } from "@/utils/url.js";
import { notify } from "@/notify";
// Fetch public share data
@@ -18,7 +18,7 @@ export async function fetchPub(path, hash, password = "") {
throw error;
}
let data = await response.json()
const adjusted = adjustedData(data, removePrefix(getApiPath(`share/${hash}${path}`)));
const adjusted = adjustedData(data, `/share/${hash}${path}`);
return adjusted
}
@@ -37,7 +37,6 @@ export function download(share, ...files) {
}
fileargs = fileargs.slice(0, -2); // remove trailing "||"
const params = {
"path": removePrefix(share.path, "share"),
"files": fileargs,
"hash": share.hash,
"token": share.token,
+4 -4
View File
@@ -8,12 +8,12 @@ export async function list() {
return fetchJSON(apiPath);
}
export async function get(path, hash) {
export async function get(path, source) {
try {
const params = { path, hash };
const params = { path, source };
const apiPath = getApiPath("api/share",params);
let data = fetchJSON(apiPath);
return adjustedData(data, `api/share${path}`);
return adjustedData(data, path);
} catch (err) {
notify.showError(err.message || "Error fetching data");
throw err;
@@ -29,7 +29,7 @@ export async function remove(hash) {
}
export async function create(path, source, password = "", expires = "", unit = "hours") {
const params = { path: path, source: source };
const params = { path: encodeURIComponent(path), source: source };
const apiPath = getApiPath("api/share",params);
let body = "{}";
if (password != "" || expires !== "" || unit !== "hours") {
+1
View File
@@ -64,6 +64,7 @@ export function adjustedData(data, url) {
data.items = data.items.map((item) => {
item.url = `${data.url}${encodeURIComponent(item.name)}`;
item.source = data.source
if (data.path == "/") {
item.path = `/${item.name}`
} else {
+8 -2
View File
@@ -12,7 +12,13 @@
<span class="chevron"><i class="material-icons">keyboard_arrow_right</i></span>
<router-link :to="link.url">{{ link.name }}</router-link>
</span>
<action style="display: contents" v-if="showShare" icon="share" show="share" />
<action
aria-label="Show-Share"
style="display: contents"
v-if="showShare"
icon="share"
show="share"
/>
<div v-if="isCardView">
Size:
<input
@@ -67,7 +73,7 @@ export default {
let breadcrumbs = [];
let buildRef = this.base;
parts.forEach((element) => {
buildRef = buildRef + encodeURIComponent(element) + "/";
buildRef = buildRef + encodeURIComponent(decodeURIComponent(element)) + "/";
breadcrumbs.push({
name: decodeURIComponent(element),
url: buildRef,
@@ -232,7 +232,7 @@ export default {
window.location.href = this.getRelative(path);
},
getUrl() {
return url.removePrefix(this.url);
return this.url;
},
onRightClick(event) {
event.preventDefault(); // Prevent default context menu
+13 -26
View File
@@ -129,9 +129,7 @@ import { notify } from "@/notify";
import { state, getters, mutations } from "@/store";
import { shareApi, publicApi } from "@/api";
import { fromNow } from "@/utils/moment";
import { removePrefix } from "@/utils/url";
import Clipboard from "clipboard";
import { baseURL } from "@/utils/constants";
export default {
name: "share",
@@ -178,30 +176,21 @@ export default {
},
},
async beforeMount() {
let path = state.req.path;
this.source = state.req.source;
if (state.isSearchActive) {
path = state.selected[0].path;
this.source = state.selected[0].source;
} else if (getters.selectedCount() === 1) {
const selected = getters.getFirstSelected();
path = selected.path;
this.source = selected.source;
this.source = state.req.items[state.selected[0]].source;
}
this.subpath = decodeURIComponent(path);
try {
let path = getters.routePath(baseURL);
if (state.isSearchActive) {
path = state.selected[0].path;
this.source = state.selected[0].source;
} else {
this.source = state.req.source;
if (getters.selectedCount() === 1) {
if (state.sources.count > 1) {
path = removePrefix(
state.req.items[this.selected[0]].url,
"files/" + state.req.source
);
} else {
path = removePrefix(state.req.items[this.selected[0]].url, "files");
}
}
if (state.sources.count > 1) {
path = removePrefix(path, state.req.source);
}
}
this.subpath = decodeURIComponent(path);
// get last element of the path
const links = await shareApi.get(this.subpath);
const links = await shareApi.get(this.subpath, this.source);
this.links = links;
} catch (err) {
notify.showError(err);
@@ -225,9 +214,7 @@ export default {
methods: {
async submit() {
let isPermanent = !this.time || this.time === 0;
let res = null;
if (isPermanent) {
res = await shareApi.create(this.subpath, this.source, this.password);
} else {
+35 -35
View File
@@ -3,7 +3,7 @@
"cancel": "Abbrechen",
"close": "Schließen",
"copy": "Kopieren",
"copyFile": "Kopiere Datei",
"copyFile": "Datei kopieren",
"copyToClipboard": "In Zwischenablage kopieren",
"create": "Neu",
"delete": "Löschen",
@@ -11,16 +11,16 @@
"file": "Datei",
"folder": "Ordner",
"info": "Info",
"more": "mehr",
"more": "Mehr",
"move": "Verschieben",
"moveFile": "Verschiebe Datei",
"moveFile": "Datei verschieben",
"new": "Neu",
"next": "nächste",
"next": "Weiter",
"ok": "OK",
"permalink": "permanenten Verweis anzeigen",
"previous": "vorherige",
"permalink": "Permalink anzeigen",
"previous": "Zurück",
"publish": "Veröffentlichen",
"rename": "umbenennen",
"rename": "Umbenennen",
"replace": "Ersetzen",
"reportIssue": "Fehler melden",
"save": "Speichern",
@@ -29,11 +29,11 @@
"select": "Auswählen",
"selectMultiple": "Mehrfachauswahl",
"share": "Teilen",
"shell": "Kommandozeile ein/ausschalten",
"shell": "Kommandozeile ein-/ausschalten",
"submit": "Absenden",
"switchView": "Ansicht wechseln",
"toggleSidebar": "Seitenleiste anzeigen",
"update": "Update",
"update": "Aktualisieren",
"upload": "Upload",
"openFile": "Datei öffnen",
"continue": "Fortfahren"
@@ -56,8 +56,8 @@
"files": "Dateien",
"folders": "Ordner",
"home": "Home",
"lastModified": "zuletzt verändert",
"loading": "Lade...",
"lastModified": "Zuletzt geändert",
"loading": "Laden...",
"lonely": "Hier scheint nichts zu sein...",
"metadata": "Metadaten",
"multipleSelectionEnabled": "Mehrfachauswahl aktiviert",
@@ -108,13 +108,13 @@
"zhTW": "中文 (繁體)"
},
"login": {
"createAnAccount": "Account erstellen",
"loginInstead": "Account besteht bereits",
"password": "Passwort",
"passwordConfirm": "Passwort Bestätigung",
"passwordsDontMatch": "Passwörter stimmen nicht überein",
"createAnAccount": "Konto erstellen",
"loginInstead": "Bei bestehendem Konto anmelden",
"password": "Kennwort",
"passwordConfirm": "Kennwort bestätigen",
"passwordsDontMatch": "Kennwörter stimmen nicht überein",
"signup": "Registrieren",
"submit": "Login",
"submit": "Anmelden",
"username": "Benutzername",
"usernameTaken": "Benutzername ist bereits vergeben",
"wrongCredentials": "Falsche Zugangsdaten"
@@ -127,16 +127,16 @@
"deleteMessageMultiple": "Sind Sie sicher, dass Sie {count} Datei(en) löschen möchten?",
"deleteMessageSingle": "Sind Sie sicher, dass Sie diesen Ordner/diese Datei löschen möchten?",
"deleteMessageShare": "Sind Sie sicher, dass Sie diese Freigabe löschen möchten ({path})?",
"deleteTitle": "Lösche Dateien",
"deleteTitle": "Dateien löschen",
"displayName": "Anzeigename:",
"download": "Lade Dateien",
"download": "Dateien herunterladen",
"downloadMessage": "Wählen Sie ein Format zum Herunterladen aus.",
"error": "Etwas ist schief gelaufen",
"fileInfo": "Dateiinformation",
"filesSelected": "{count} Dateien ausgewählt.",
"lastModified": "Zuletzt geändert",
"move": "Verschieben",
"moveMessage": "Wählen Sie einen neuen Platz für ihre Datei(en)/Ordner:",
"moveMessage": "Wählen Sie einen neuen Ort für ihre Datei(en)/Ordner:",
"newArchetype": "Erstelle neuen Beitrag auf dem Archetyp. Ihre Datei wird im Inhalteordner erstellt.",
"newDir": "Neuer Ordner",
"newDirMessage": "Geben Sie den Namen des neuen Ordners an.",
@@ -145,7 +145,7 @@
"numberDirs": "Anzahl der Ordner",
"numberFiles": "Anzahl der Dateien",
"rename": "Umbenennen",
"renameMessage": "Fügen Sie einen Namen ein für",
"renameMessage": "Geben Sie einen Namen ein für",
"replace": "Ersetzen",
"replaceMessage": "Eine der Datei mit dem gleichen Namen, wie die Sie hochladen wollen, existiert bereits. Soll die vorhandene Datei übersprungen oder ersetzt werden?\n",
"schedule": "Plan",
@@ -155,15 +155,15 @@
"upload": "Upload",
"uploadFiles": "Upload von {files} Dateien...",
"uploadMessage": "Wählen Sie eine Upload-Methode",
"optionalPassword": "Optionales Passwort"
"optionalPassword": "Optionales Kennwort"
},
"search": {
"images": "Bilder",
"music": "Musik",
"pdf": "PDF",
"pressToSearch": "Drücken Sie Enter um zu suchen...",
"pressToSearch": "Drücken Sie Enter, um zu suchen...",
"search": "Suche...",
"typeToSearch": "Tippen um zu suchen...",
"typeToSearch": "Tippen, um zu suchen...",
"types": "Typen",
"video": "Video"
},
@@ -174,18 +174,18 @@
"allowEdit": "Bearbeiten, Umbenennen und Löschen von Dateien oder Ordnern",
"allowNew": "Erstellen neuer Dateien und Ordner",
"allowPublish": "Veröffentlichen von neuen Beiträgen und Seiten",
"allowSignup": "Erlaube Benutzern sich zu registrieren",
"avoidChanges": "(leer lassen um Änderungen zu vermeiden)",
"allowSignup": "Benutzern erlauben, sich zu registrieren",
"avoidChanges": "(leer lassen, um Änderungen zu vermeiden)",
"branding": "Design",
"brandingDirectoryPath": "Designverzeichnispfad",
"brandingHelp": "Sie können das Erscheinungsbild Ihres File Browser anpassen, in dem Sie den Namen ändern, das Logo austauchsen oder eigene Stile definieren und sogar externe Links zu GitHub deaktivieren.\nUm mehr Informationen zum Anpassen des Designs zu bekommen, gehen Sie bitte zu {0}.",
"changePassword": "Passwort ändern",
"changePassword": "Kennwort ändern",
"commandRunner": "Befehlseingabe",
"commandRunnerHelp": "Hier könne Sie Befehle eintragen, welche bei den benannten Aktionen ausgeführt werden. Sie müssen pro Zeile jeweils einen Befehl eingeben. Die Umgebungsvariable {0} und {1} sind verfügbar, wobei {0} relative zu {1} ist. Für mehr Informationen über diese Funktion und die verfügbaren Umgebungsvariablen, lesen Sie bitte die {2}.",
"commandsUpdated": "Befehle aktualisiert!",
"createUserDir": "Automatisches Erstellen des Home-Verzeichnisses beim Anlegen neuer Benutzer",
"tusUploads": "Gestückelter Upload",
"tusUploadsHelp": "File Browser unterstützt das Hochladen von gestückelten Dateien und ermöglicht so einen effizienten, zuverlässigen, fortsetzbaren und gestückelten Datei-Upload auch in unzuverlässigen Netzwerken.",
"tusUploadsHelp": "File Browser unterstützt das Hochladen von gestückelten Dateien und ermöglicht so einen effizienten, zuverlässigen und fortsetzbaren Datei-Upload auch in unzuverlässigen Netzwerken.",
"tusUploadsChunkSize": "Gibt die maximale Größe pro Anfrage an (direkte Uploads werden für kleinere Uploads verwendet). Bitte geben Sie eine Byte-Angabe oder eine Zeichenfolge wie 10 MB, 1 GB usw. an",
"tusUploadsRetryCount": "Anzahl der Wiederholungsversuche, wenn das Hochladen eines Stückes fehlschlägt.",
"customStylesheet": "Individuelles Stylesheet",
@@ -194,7 +194,7 @@
"disableUsedDiskPercentage": "Diagramm zur Festplattennutzung deaktivieren",
"documentation": "Dokumentation",
"examples": "Beispiele",
"executeOnShell": "In Shell ausführen",
"executeOnShell": "In Kommandozeile ausführen",
"executeOnShellDescription": "Es ist voreingestellt das der File Brower Befehle ausführt in dem er die Befehlsdateien direkt aufruft. Wenn Sie wollen, dass sie über einer Kommandozeile (wie Bash oder PowerShell) laufen, könne Sie diese hier definieren mit allen bennötigten Argumenten und Optionen. Wenn gesetzt, wird das Kommando das ausgeführt werden soll als Parameter angehängt. Das gilt für Benuzerkommandos sowie auch für Ereignisse.",
"globalRules": "Das ist ein globales Set von Regeln die erlauben oder nicht erlauben. Die sind für alle Benutzer zutreffend. Es können spezielle Regeln in den Einstellungen der Benutzer definiert werden, die diese überschreiben.",
"globalSettings": "Globale Einstellungen",
@@ -206,15 +206,15 @@
"newPassword": "Ihr neues Passwort.",
"newPasswordConfirm": "Bestätigen Sie Ihr neues Passwort",
"newUser": "Neuer Benutzer",
"password": "Passwort",
"passwordUpdated": "Passwort aktualisiert!",
"password": "Kennwort",
"passwordUpdated": "Kennwort aktualisiert!",
"path": "Pfad",
"perm": {
"create": "Dateien und Ordner erstellen",
"delete": "Dateien und Ordner löschen",
"download": "Download",
"execute": "Befehle ausführen",
"modify": "Dateien editieren",
"modify": "Dateien bearbeiten",
"rename": "Umbenennen oder Verschieben von Dateien oder Ordnern",
"share": "Datei teilen"
},
@@ -222,7 +222,7 @@
"permissionsHelp": "Sie können einem Benutzer Administratorrechte einräumen oder die Berechtigunen individuell festlegen. Wenn Sie \"Administrator\" auswählen, werden alle anderen Rechte automatisch vergeben. Die Nutzerverwaltung kann nur durch einen Administrator erfolgen.\n",
"profileSettings": "Profileinstellungen",
"ruleExample1": "Verhindert den Zugang zu versteckten Dateien (dot-Files, wie .git, .gitignore) in allen Ordnern\n",
"ruleExample2": "blockiert den Zugang auf Dateien mit dem Namen Caddyfile in der Wurzel/Basis des Scopes.",
"ruleExample2": "Blockiert den Zugang auf Dateien mit dem Namen Caddyfile in der Wurzel/Basis des Scopes.",
"rules": "Regeln",
"rulesHelp": "Hier können Sie erlaubte und verbotene Aktionen für einen einzelnen Benutzer festlegen. Blockierte Dateien werden nicht im Listing angezeigt und sind nicht erreichbar für den Nutzer. Wir unterstützen reguläre Ausdrücke (Regex) und Pfade die relativ zum Benutzerordner sind. \n",
"scope": "Scope",
@@ -245,8 +245,8 @@
"userDeleted": "Benutzer gelöscht!",
"userManagement": "Benutzerverwaltung",
"userUpdated": "Benutzer aktualisiert!",
"username": "Nutzername",
"users": "Nutzer"
"username": "Benutzername",
"users": "Benutzer"
},
"sidebar": {
"help": "Hilfe",
+16 -10
View File
@@ -22,13 +22,12 @@ export default function download() {
format: files.length ? "zip" : null,
};
// Perform download without opening a new window
publicApi.download(share, ...files);
startDownload(share, files, true);
return;
}
if (getters.isSingleFileSelected()) {
// Single file download without new window
filesApi.download(null, [getters.selectedDownloadUrl()]);
startDownload(null, [getters.selectedDownloadUrl()]);
return;
}
@@ -45,13 +44,20 @@ export default function download() {
} else {
files.push(state.route.path);
}
try {
// Initiate download without new window
filesApi.download(format, files);
notify.showSuccess("Download started");
} catch (e) {
notify.showError("Error downloading", e);
}
startDownload(format, files);
},
});
}
async function startDownload(config,files, isPublic) {
try {
if (isPublic) {
publicApi.download(config, files);
} else {
filesApi.download(config, files);
}
notify.showSuccess("Downloading...");
} catch (e) {
notify.showError("Error downloading", e);
}
}
+7 -2
View File
@@ -87,6 +87,7 @@ import ExtendedImage from "@/components/files/ExtendedImage.vue";
import { state, getters, mutations } from "@/store";
import { getFileExtension } from "@/utils/files";
import { convertToVTT } from "@/utils/subtitles";
import { getTypeInfo } from "@/utils/mimetype";
export default {
name: "preview",
@@ -256,14 +257,18 @@ export default {
let composedListing = this.listing[j];
composedListing.path = directoryPath + "/" + composedListing.name;
this.previousLink = composedListing.url;
this.previousRaw = this.prefetchUrl(composedListing);
if (getTypeInfo(composedListing.type).simpleType == "image") {
this.previousRaw = this.prefetchUrl(composedListing);
}
break;
}
for (let j = i + 1; j < this.listing.length; j++) {
let composedListing = this.listing[j];
composedListing.path = directoryPath + "/" + composedListing.name;
this.nextLink = composedListing.url;
this.nextRaw = this.prefetchUrl(composedListing);
if (getTypeInfo(composedListing.type).simpleType == "image") {
this.nextRaw = this.prefetchUrl(composedListing);
}
break;
}
return;
-29
View File
@@ -1,29 +0,0 @@
import { test as base, expect, Page } from "@playwright/test";
export const test = base.extend<{ checkForErrors: () => void }>({
checkForErrors: async ({ page }, use) => {
const { checkForErrors } = setupErrorTracking(page);
await use(checkForErrors);
},
});
// Error tracking function
export function setupErrorTracking(page: Page) {
const errors: string[] = [];
page.on("console", (message) => {
if (message.type() === "error") {
errors.push(message.text());
}
});
return {
checkForErrors: () => {
if (errors.length > 0) {
console.error("Console Errors Detected:", errors);
}
expect(errors).toHaveLength(0);
},
};
}
export { expect };
File renamed without changes.
@@ -0,0 +1,88 @@
import { test, expect } from "../test-setup";
test("breadcrumbs navigation checks", async ({ page, checkForErrors, context }) => {
await page.goto("/files/");
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
const shareHash = await page.evaluate(() => localStorage.getItem('shareHash'));
if (shareHash == "") {
throw new Error("Share hash not found in localStorage");
}
await page.goto("/share/" + shareHash);
await expect(page).toHaveTitle("Graham's Filebrowser - Share - myfolder");
await expect(page.locator('a[aria-label="Home"]')).toHaveAttribute("href", `/share/${shareHash}/`);
await page.dblclick('a[aria-label="testdata"]');
await expect(page).toHaveTitle("Graham's Filebrowser - Share - testdata");
// Ensure no <span> children exist directly under .breadcrumbs (ie no breadcrumbs paths)
let spanChildrenCount = await page.locator('.breadcrumbs > span').count();
await page.waitForSelector('.breadcrumbs');
expect(spanChildrenCount).toBe(1);
checkForErrors();
});
test("root share path is valid", async ({ page, checkForErrors, context }) => {
await page.goto("/files/");
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
await page.locator('button[aria-label="Show-Share"]').waitFor({ state: 'visible' });
await page.locator('button[aria-label="Show-Share"]').click();
await expect(page.locator('div[aria-label="share-path"]')).toHaveText('Path: /');
checkForErrors();
});
test("share download single file", async ({ page, checkForErrors, context }) => {
await page.goto("/files/");
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
const shareHash = await page.evaluate(() => localStorage.getItem('shareHash'));
if (shareHash == "") {
throw new Error("Share hash not found in localStorage");
}
await page.goto("/share/" + shareHash + "/testdata/");
await expect(page).toHaveTitle("Graham's Filebrowser - Share - testdata");
await page.locator('a[aria-label="gray-sample.jpg"]').click({ button: "right" });
await page.locator('button[aria-label="Download"]').waitFor({ state: 'visible' });
await page.locator('button[aria-label="Download"]').click();
const popup = page.locator('#popup-notification-content');
await popup.waitFor({ state: 'visible' });
await expect(popup).toHaveText("Downloading...");
checkForErrors();
});
test("share download multiple files", async ({ page, checkForErrors, context }) => {
await page.goto("/files/");
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
const shareHash = await page.evaluate(() => localStorage.getItem('shareHash'));
if (shareHash == "") {
throw new Error("Share hash not found in localStorage");
}
await page.goto("/share/" + shareHash + "/testdata/");
await expect(page).toHaveTitle("Graham's Filebrowser - Share - testdata");
await page.locator('a[aria-label="gray-sample.jpg"]').click({ button: "right" });
await page.locator('button[aria-label="Select multiple"]').waitFor({ state: 'visible' });
await page.locator('button[aria-label="Select multiple"]').click();
const popup = page.locator('#popup-notification-content');
await popup.waitFor({ state: 'visible' });
await expect(popup).toHaveText("Multiple Selection Enabled");
await page.locator('a[aria-label="20130612_142406.jpg"]').click();
await page.locator('a[aria-label="IMG_2578.JPG"]').click();
await page.locator('a[aria-label="gray-sample.jpg"]').click({ button: "right" });
await page.locator('.selected-count-header').waitFor({ state: 'visible' });
await expect(page.locator('.selected-count-header')).toHaveText('3 selected');
await page.locator('button[aria-label="Download"]').waitFor({ state: 'visible' });
await page.locator('button[aria-label="Download"]').click();
const popup2 = page.locator('#popup-notification-content');
await popup2.waitFor({ state: 'visible' });
await expect(popup2).toHaveText("Downloading...");
checkForErrors();
});
@@ -10,13 +10,13 @@ async function globalSetup() {
await page.getByPlaceholder("Username").fill("admin");
await page.getByPlaceholder("Password").fill("admin");
await page.getByRole("button", { name: "Login" }).click();
await page.waitForURL("**/files/", { timeout: 100 });
await page.waitForURL("**/files/", { timeout: 250 });
const cookies = await context.cookies();
expect(cookies.find((c) => c.name === "auth")?.value).toBeDefined();
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
await page.waitForURL("**/files/playwright-files", { timeout: 100 });
await page.waitForURL("**/files/playwright-files", { timeout: 250 });
// Create a share
await page.locator('a[aria-label="myfolder"]').waitFor({ state: 'visible' });
@@ -24,7 +24,7 @@ async function globalSetup() {
await page.locator('.selected-count-header').waitFor({ state: 'visible' });
await expect(page.locator('.selected-count-header')).toHaveText('1 selected');
await page.locator('button[aria-label="Share"]').click();
await expect(page.locator('div[aria-label="share-path"]')).toHaveText('Path: /myfolder/');
await expect(page.locator('div[aria-label="share-path"]')).toHaveText('Path: /myfolder');
await page.locator('button[aria-label="Share-Confirm"]').click();
await expect(page.locator("#share .card-content table tbody tr:not(:has(th))")).toHaveCount(1);
const shareHash = await page.locator("#share .card-content table tbody tr:not(:has(th)) td").first().textContent();
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test";
import { test, expect } from "../test-setup";
test("Create first new file", async ({ page, context }) => {
test("Create first new file", async ({ page, checkForErrors, context }) => {
await page.goto("/");
await expect(page.locator('#listingView .message > span')).toHaveText('It feels lonely here...');
await page.locator('#listingView').click({ button: "right" });
@@ -10,4 +10,5 @@ test("Create first new file", async ({ page, context }) => {
await expect(page).toHaveTitle("Graham's Filebrowser - Files - test.txt");
await page.locator('button[aria-label="Close"]').click();
await expect(page.locator('#listingView .file-items')).toHaveCount(1);
checkForErrors();
});
+48
View File
@@ -0,0 +1,48 @@
import { test as base, expect, Page } from "@playwright/test";
export const test = base.extend<{ checkForErrors: (expectedConsoleErrors?: number, expectedApiErrors?: number) => void }>({
checkForErrors: async ({ page }, use) => {
const { checkForErrors } = setupErrorTracking(page);
await use(checkForErrors);
},
});
// Error tracking function
export function setupErrorTracking(page: Page) {
const consoleErrors: string[] = [];
const failedResponses: { url: string; status: number }[] = [];
// Track console errors
page.on("console", (message) => {
if (message.type() === "error") {
consoleErrors.push(message.text());
}
});
// Track failed API calls
page.on("response", (response) => {
if (!response.ok()) {
failedResponses.push({
url: response.url(),
status: response.status(),
});
}
});
return {
checkForErrors: (expectedConsoleErrors = 0, expectedApiErrors = 0) => {
if (consoleErrors.length !== expectedConsoleErrors) {
console.error("Unexpected Console Errors:", consoleErrors);
}
if (failedResponses.length !== expectedApiErrors) {
console.error("Unexpected Failed API Calls:", failedResponses);
}
expect(consoleErrors).toHaveLength(expectedConsoleErrors);
expect(failedResponses).toHaveLength(expectedApiErrors);
},
};
}
export { expect };
-25
View File
@@ -1,25 +0,0 @@
import { test, expect } from "../test-setup";
test("breadcrumbs navigation checks", async ({ page, checkForErrors, context }) => {
await page.goto("/files/");
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-files");
const shareHash = await page.evaluate(() => localStorage.getItem('shareHash'));
if (shareHash == "") {
throw new Error("Share hash not found in localStorage");
}
await page.goto("/share/" + shareHash);
await expect(page).toHaveTitle("Graham's Filebrowser - Share - myfolder");
await expect(page.locator('a[aria-label="Home"]')).toHaveAttribute("href", `/share/${shareHash}/`);
await page.dblclick('a[aria-label="testdata"]');
await expect(page).toHaveTitle("Graham's Filebrowser - Share - testdata");
// Ensure no <span> children exist directly under .breadcrumbs (ie no breadcrumbs paths)
let spanChildrenCount = await page.locator('.breadcrumbs > span').count();
await page.waitForSelector('.breadcrumbs');
expect(spanChildrenCount).toBe(1);
checkForErrors();
});
+1 -1
View File
@@ -20,6 +20,6 @@
},
"checkJs": false, // check later
},
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.vue", "tests/auth.spec.ts"],
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.vue", "tests-playwright/general/auth.spec.ts"],
"exclude": ["node_modules", "dist"]
}
+1 -1
View File
@@ -1,7 +1,7 @@
.SILENT:
setup:
echo "creating ./backend/test_config.yaml for local testing..." && \
if [ ! -f backend/test__config.yaml ]; then \
if [ ! -f backend/test_config.yaml ]; then \
cp backend/config.yaml backend/test_config.yaml; \
fi
echo "installing swagger needed to generate backend api docs..." && \