mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-15 21:45:55 -05:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79552f8adb | ||
|
|
951debcd87 | ||
|
|
cd8519c8aa | ||
|
|
da085bca69 | ||
|
|
64250ffff0 | ||
|
|
0bc8889c00 | ||
|
|
6eaead073a | ||
|
|
826b060bb1 | ||
|
|
21dfc6169e | ||
|
|
4708faec5f | ||
|
|
fa5abc8c67 |
No files matched your search
@@ -2,6 +2,79 @@
|
||||
|
||||
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).
|
||||
|
||||
## v1.5.2
|
||||
|
||||
**Notes**:
|
||||
- [docker] upgraded ffmpeg version 8.1.1 to 8.1.2
|
||||
|
||||
**BugFixes**:
|
||||
- Fixed OnlyOffice reopening an older editor state after a document is modified (#2633) (#2578).
|
||||
- Cannot "Reset and generate new two-factor code" to reset the TOTP for a user (#2399) (#2641).
|
||||
|
||||
## v1.5.1
|
||||
|
||||
**BugFixes**:
|
||||
- fix http config section being dropped so trustedHeaders and disableRateLimit apply (#2602) (#2560)
|
||||
- fix upload shares with password (#2589) (#2573)
|
||||
- fix token when returning from preview on shares with pass (#2588) (#2465)
|
||||
- fix share undefined url after editing (#2567) (#2523)
|
||||
|
||||
## v1.5.0
|
||||
|
||||
**New Features**:
|
||||
- Added basic html viewer with relative reference support (#2522)
|
||||
- Shares can have pinned files, requires a user to have edit access to share (#2522)
|
||||
- Enhanced search
|
||||
- now uses "lazy" match by default. (#2509)
|
||||
- added missing `case sensitive` option in the UI
|
||||
- Progressive Web App (PWA) improvements
|
||||
- restored install prompt with sidebar install button (#2086)
|
||||
- camera and video capture buttons on upload (mobile-friendly `capture` inputs)
|
||||
- send files to other apps via the Web Share API (`Send to app` in the context menu)
|
||||
- App notifications for file operations (#2478)
|
||||
- optional browser notifications when uploads, chunked downloads, move/copy, or failures finish while the tab is in the background
|
||||
- single on/off toggle in Notifications settings, stored in browser local storage
|
||||
|
||||
**Notes**:
|
||||
- [docker] upgraded ffmpeg version 8.1 to 8.1.1
|
||||
|
||||
**BugFixes**:
|
||||
- fixed PWA manifest `scope` and `id` so install works when the app is served under a base URL
|
||||
- installing a public share as a PWA now opens the share URL instead of the site root (#2302)
|
||||
|
||||
## v1.4.4
|
||||
|
||||
**BugFixes**:
|
||||
- Pinning/Unpinning file resets users' scope permission (#2532)
|
||||
|
||||
## v1.4.3
|
||||
|
||||
**Security**:
|
||||
- [High] Path traversal in subtitle handler allows any authenticated user to read arbitrary files (GHSA-vvp7-h4fj-m28w)
|
||||
|
||||
**New Features**:
|
||||
- pinned files/folders (#2396) (#2510)
|
||||
- Markdown Image relative reference support (#2355)
|
||||
- Add an option to create a new folder for unarchiving (#2338)
|
||||
|
||||
**Notes**:
|
||||
- added fallback to show text in notification if copy fails (#2517)
|
||||
- added `alt`+`arrow up` shortcut as alias of `backspace` to go into parent directory (#2501) (#2521)
|
||||
- added `alt`+`arrow down` shortcut as alias of `enter` to open files in Listing View (#2501) (#2521)
|
||||
- updated help menu with better translations
|
||||
- migrate i18n to v11 (#2472) (#2504)
|
||||
- migrate eslint (#2459)
|
||||
- improved preview cancellation to improve performance when navigating UI.
|
||||
|
||||
**BugFixes**:
|
||||
- fix lyrics regex parsing (#2505)
|
||||
- fix folder previews issue (#2487) (#2492)
|
||||
- fix accidental exit on images while using gestures (#2508)
|
||||
- navigating using the up/down arrow keys in Listing View was "jumping randomly" in some view modes (#2521)
|
||||
- socket field in config.yaml is ignored (#2497)
|
||||
- fix keep opened file selected after closing its preview @anpryl (#2515)
|
||||
|
||||
|
||||
## v1.4.2
|
||||
|
||||
**Security**:
|
||||
|
||||
+7
-64
@@ -5,17 +5,22 @@ Thank you for your interest in contributing to FileBrowser Quantum! This guide w
|
||||
## Prerequisites
|
||||
|
||||
- **Go 1.25+** (see `backend/go.mod`)
|
||||
- **Node.js 20.0.0+** with npm 9.0.0+ (see `frontend/package.json`)
|
||||
- **Node.js 22.0.0+** with npm 9.0.0+ (see `frontend/package.json`)
|
||||
- **Docker** (optional, for containerized development)
|
||||
- **Git** especially improtant on windows -- needed for bash support.
|
||||
|
||||
### Optional Tools
|
||||
|
||||
- **ffmpeg**: For media features (subtitles, thumbnails, heic)
|
||||
- **ffmpeg/ffprobe**: For media features (subtitles, thumbnails, heic)
|
||||
- Ubuntu/Debian: `sudo apt-get install ffmpeg`
|
||||
- macOS: `brew install ffmpeg`
|
||||
- Windows: Download from [ffmpeg.org](https://ffmpeg.org/download.html)
|
||||
|
||||
- **exiftool**: For photo metadata processing (RAW/HEIC previews, EXIF orientation)
|
||||
- Ubuntu/Debian: `sudo apt-get install libimage-exiftool-perl`
|
||||
- macOS: `brew install exiftool`
|
||||
- Windows: Download from [exiftool.org](https://exiftool.org/) (install `exiftool.exe` and add it to your PATH, or set `integrations.media.exiftoolPath` in config)
|
||||
|
||||
- **mupdf-tools**: For PDF preview generation
|
||||
- Ubuntu/Debian: `sudo apt-get install mupdf-tools`
|
||||
- macOS: `brew install mupdf-tools`
|
||||
@@ -90,18 +95,6 @@ make test-playwright # E2E tests in Docker
|
||||
|
||||
E2E tests run with three authentication modes: standard auth, no auth, and proxy auth.
|
||||
|
||||
### Coverage & Performance
|
||||
```bash
|
||||
cd backend
|
||||
./run_check_coverage.sh # Coverage report with HTML output
|
||||
./run_benchmark.sh # Benchmarks
|
||||
```
|
||||
|
||||
**Code Coverage:**
|
||||
- View report: Open `backend/coverage.html` after running coverage script
|
||||
- CI enforces coverage for critical packages
|
||||
- Use `go test -cover` for quick package coverage
|
||||
|
||||
## Code Standards
|
||||
|
||||
### Backend (Go)
|
||||
@@ -156,53 +149,3 @@ type(scope): description
|
||||
|
||||
Types: feat, fix, docs, refactor, test, chore
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
|
||||
Check the [Project Roadmap](https://github.com/users/gtsteffaniak/projects/4/views/2) to see issues sorted by priority. This helps you understand what features are planned and where you can contribute most effectively.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Build failures:**
|
||||
```bash
|
||||
# Frontend
|
||||
cd frontend && rm -rf node_modules && npm install
|
||||
|
||||
# Backend
|
||||
cd backend && go mod tidy && go clean -modcache
|
||||
```
|
||||
|
||||
**Authentication Issues:**
|
||||
|
||||
Always first enable debug logging in your config file if you have issues.
|
||||
|
||||
1. **OIDC Login Fails:**
|
||||
- Check redirect URLs match your config
|
||||
- Verify OIDC provider settings
|
||||
- Enable debug logs to see auth flow
|
||||
- Common issue: mismatched callback URLs
|
||||
|
||||
2. **Proxy Auth Not Working:**
|
||||
- Verify header names match config
|
||||
- Check nginx/reverse proxy passes headers
|
||||
- Test with: `curl -H "X-Auth: username" localhost:8080`
|
||||
- Enable `--log-level debug` to see headers
|
||||
|
||||
3. **TOTP Issues:**
|
||||
- Ensure server time is synchronized
|
||||
- Check QR code generation in logs
|
||||
- Test with authenticator app time settings
|
||||
- Database might have stale TOTP secrets
|
||||
|
||||
4. **Session/Cookie Problems:**
|
||||
- Clear browser cookies and localStorage
|
||||
- Verify cookie domain settings
|
||||
- Try incognito/private browsing mode
|
||||
|
||||
### Getting Help
|
||||
|
||||
- **Wiki**: [Project Wiki](https://github.com/gtsteffaniak/filebrowser/wiki)
|
||||
- **Issues**: [GitHub Issues](https://github.com/gtsteffaniak/filebrowser/issues)
|
||||
- **PR Template**: See `.github/PULL_REQUEST_TEMPLATE.md`
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
## Pinned
|
||||
|
||||
:loudspeaker: [New Announcement](https://github.com/gtsteffaniak/filebrowser/discussions/2048)
|
||||
|
||||
:pushpin: [Read The Official Docs](https://filebrowserquantum.com/) (currently english-only)
|
||||
|
||||
## About
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM gtstef/ffmpeg:8.1-decode AS ffmpeg
|
||||
FROM gtstef/ffmpeg:8.1.2-decode AS ffmpeg
|
||||
FROM golang:alpine AS base
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
|
||||
@@ -357,7 +357,7 @@ func TestOverrideDirectoryToFile(t *testing.T) {
|
||||
{Name: "Test Object", Type: "directory"},
|
||||
},
|
||||
}
|
||||
idx.UpdateMetadata(rootInfo, nil) // nil scanner for test
|
||||
idx.UpdateMetadata(rootInfo, nil, true) // nil scanner for test
|
||||
|
||||
// Delete the old directory item from the database before replacing it with a file
|
||||
idx.DeleteMetadata("/Test Object", true, false)
|
||||
@@ -375,7 +375,7 @@ func TestOverrideDirectoryToFile(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
idx.UpdateMetadata(rootInfo, nil) // nil scanner for test
|
||||
idx.UpdateMetadata(rootInfo, nil, true) // nil scanner for test
|
||||
|
||||
// Verify the directory was replaced with a file in the mock data
|
||||
rootInfo, exists := idx.GetMetadataInfo("/", true, false)
|
||||
@@ -467,7 +467,7 @@ func TestOverrideFileToDirectory(t *testing.T) {
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "Test Object", Size: 12}}, // Length of "test content"
|
||||
},
|
||||
}
|
||||
idx.UpdateMetadata(rootInfo, nil) // nil scanner for test
|
||||
idx.UpdateMetadata(rootInfo, nil, true) // nil scanner for test
|
||||
|
||||
// Delete the old file item from the database before replacing it with a directory
|
||||
idx.DeleteMetadata("/Test Object", false, false)
|
||||
@@ -483,7 +483,7 @@ func TestOverrideFileToDirectory(t *testing.T) {
|
||||
Type: "directory",
|
||||
},
|
||||
}
|
||||
idx.UpdateMetadata(rootInfo, nil) // nil scanner for test
|
||||
idx.UpdateMetadata(rootInfo, nil, true) // nil scanner for test
|
||||
|
||||
// Verify the file was replaced with a directory in the mock data
|
||||
rootInfo, exists := idx.GetMetadataInfo("/", true, false)
|
||||
|
||||
@@ -27,6 +27,8 @@ import (
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
|
||||
var reDuration = regexp.MustCompile(`^\[(?:(\d{1,2}):)?(\d{1,2}):(\d{1,2})\.(\d+)\](.*)`)
|
||||
|
||||
// CheckPermissionsFunc allows tests to override CheckPermissions behavior
|
||||
var CheckPermissionsFunc = checkPermissionsImpl
|
||||
|
||||
@@ -87,7 +89,7 @@ func processDirectoryMetadata(response *iteminfo.ExtendedFileInfo, idx *indexing
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// finalizeResponse handles final response adjustments (OnlyOffice ID, scope stripping)
|
||||
// finalizeResponse handles final response adjustments (OnlyOffice ID, scope stripping).
|
||||
func finalizeResponse(response *iteminfo.ExtendedFileInfo, info *iteminfo.FileInfo, realPath string, user *users.User, userScope string) {
|
||||
// Add OnlyOffice ID if applicable
|
||||
if settings.Config.Integrations.OnlyOffice.Secret != "" && info.Type != "directory" && iteminfo.IsOnlyOffice(info.Name) {
|
||||
@@ -221,12 +223,12 @@ func GetDirItems(opts utils.FileOptions, access *access.Storage, user *users.Use
|
||||
// FileInfoFasterFunc is a variable that can be mocked in tests
|
||||
var FileInfoFasterFunc = fileInfoFasterImpl
|
||||
|
||||
func FileInfoFaster(opts utils.FileOptions, access *access.Storage, user *users.User, share *share.Storage) (*iteminfo.ExtendedFileInfo, error) {
|
||||
return FileInfoFasterFunc(opts, access, user, share)
|
||||
func FileInfoFaster(opts utils.FileOptions, access *access.Storage, user *users.User, shareStore *share.Storage) (*iteminfo.ExtendedFileInfo, error) {
|
||||
return FileInfoFasterFunc(opts, access, user, shareStore)
|
||||
}
|
||||
|
||||
// fileInfoFasterImpl is the actual implementation of FileInfoFaster
|
||||
func fileInfoFasterImpl(opts utils.FileOptions, access *access.Storage, user *users.User, share *share.Storage) (*iteminfo.ExtendedFileInfo, error) {
|
||||
func fileInfoFasterImpl(opts utils.FileOptions, access *access.Storage, user *users.User, shareStore *share.Storage) (*iteminfo.ExtendedFileInfo, error) {
|
||||
response := &iteminfo.ExtendedFileInfo{}
|
||||
indexPath, userScope, topLevelErr := CheckPermissions(opts, access, user)
|
||||
accessRulesErr := topLevelErr != nil && topLevelErr == errors.ErrAccessDenied && indexPath != ""
|
||||
@@ -266,17 +268,29 @@ func fileInfoFasterImpl(opts utils.FileOptions, access *access.Storage, user *us
|
||||
response.FileInfo = *info
|
||||
response.RealPath = filepath.Join(idx.Path, indexPath)
|
||||
response.Source = opts.Source
|
||||
if share != nil && user.Permissions.Share && opts.ShowSharedAttr {
|
||||
if shareStore != nil && user.Permissions.Share && opts.ShowSharedAttr {
|
||||
for i := range response.Files {
|
||||
file := &response.Files[i]
|
||||
file.IsShared = share.IsShared(response.Path+file.Name, idx.Path, user.ID)
|
||||
file.IsShared = shareStore.IsShared(response.Path+file.Name, idx.Path, user.ID)
|
||||
}
|
||||
for i := range response.Folders {
|
||||
folder := &response.Folders[i]
|
||||
folder.IsShared = share.IsShared(response.Path+folder.Name, idx.Path, user.ID)
|
||||
folder.IsShared = shareStore.IsShared(response.Path+folder.Name, idx.Path, user.ID)
|
||||
}
|
||||
response.IsShared = share.IsShared(response.Path, idx.Path, user.ID)
|
||||
response.IsShared = shareStore.IsShared(response.Path, idx.Path, user.ID)
|
||||
}
|
||||
if info.Type == "directory" && opts.ShowPinnedItems {
|
||||
if opts.ShareHash != "" && shareStore != nil {
|
||||
if link, err := shareStore.GetByHash(opts.ShareHash); err == nil {
|
||||
if shareRelDir, err := link.ShareRelativeDir(response.Path); err == nil {
|
||||
response.PinnedItems = link.PinnedItems.NamesForDirectory(shareRelDir)
|
||||
}
|
||||
}
|
||||
} else if source, ok := users.ResolveSourceKey(response.Source); ok {
|
||||
response.PinnedItems = user.PinnedNamesForDirectory(source.Path, response.Path)
|
||||
}
|
||||
}
|
||||
|
||||
defer finalizeResponse(response, info, response.RealPath, user, userScope)
|
||||
if opts.SkipExtendedAttrs {
|
||||
if info.Type == "directory" && opts.HideFileExt != "" {
|
||||
@@ -381,13 +395,12 @@ func generateOfficeId(realPath string) string {
|
||||
func parseLRC(raw string) []iteminfo.Lyric {
|
||||
var lines []iteminfo.Lyric
|
||||
scanner := bufio.NewScanner(strings.NewReader(raw))
|
||||
re := regexp.MustCompile(`^\[(?:(\d{1,2}):)?(\d{1,2}):(\d{1,2})\.(\d+)\](.*)`)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
matches := re.FindStringSubmatch(line)
|
||||
matches := reDuration.FindStringSubmatch(line)
|
||||
if len(matches) == 6 {
|
||||
// Hours default to 0 (if not present in the timestamps)
|
||||
h := 0
|
||||
|
||||
@@ -150,7 +150,7 @@ func VerifyTotpCode(user *users.User, code string, userStore *users.Storage) err
|
||||
if !found && user.TOTPSecret == "" {
|
||||
return fmt.Errorf("OTP token not found in cache, please generate a new one")
|
||||
}
|
||||
useCache := found && user.TOTPSecret == ""
|
||||
useCache := found
|
||||
totpSecret := user.TOTPSecret // The encrypted or plaintext secret
|
||||
totpNonce := user.TOTPNonce // The nonce if encrypted, or empty if plaintext
|
||||
if useCache {
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -63,6 +62,9 @@ func Initialize(configFile string) {
|
||||
}
|
||||
|
||||
func setupServer() {
|
||||
if Config.Server.Socket != "" && (Config.Server.TLSCert != "" || Config.Server.TLSKey != "") {
|
||||
logger.Fatal("server.socket cannot be used with tlsCert or tlsKey")
|
||||
}
|
||||
if Config.Server.ListenAddress == "" {
|
||||
Config.Server.ListenAddress = "0.0.0.0"
|
||||
}
|
||||
@@ -855,6 +857,7 @@ func loadConfigWithDefaults(configFile string, generate bool) error {
|
||||
"integrations": true,
|
||||
"frontend": true,
|
||||
"userDefaults": true,
|
||||
"http": true,
|
||||
}
|
||||
|
||||
filteredConfig := make(map[string]interface{})
|
||||
@@ -971,12 +974,6 @@ func loadEnvConfig() {
|
||||
}
|
||||
|
||||
func SetDefaults(generate bool) Settings {
|
||||
// get number of CPUs available
|
||||
numCpus := 4 // default to 4 CPUs if runtime.NumCPU() fails or is not available
|
||||
cpus := runtime.NumCPU()
|
||||
if cpus > 0 && !generate {
|
||||
numCpus = cpus
|
||||
}
|
||||
database := os.Getenv("FILEBROWSER_DATABASE")
|
||||
if database == "" {
|
||||
database = "database.db"
|
||||
@@ -987,7 +984,7 @@ func SetDefaults(generate bool) Settings {
|
||||
s := Settings{
|
||||
Server: Server{
|
||||
Port: 80,
|
||||
NumImageProcessors: numCpus,
|
||||
NumImageProcessors: 4,
|
||||
BaseURL: "",
|
||||
Database: database,
|
||||
SourceMap: map[string]*Source{},
|
||||
|
||||
@@ -94,6 +94,34 @@ func TestConfigLoadEnvVars(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigLoadHttpSection(t *testing.T) {
|
||||
testDir := t.TempDir()
|
||||
configContent := []byte(`
|
||||
server:
|
||||
sources:
|
||||
- path: "."
|
||||
http:
|
||||
trustedHeaders:
|
||||
- X-Forwarded-For
|
||||
disableRateLimit: true
|
||||
`)
|
||||
configFile := filepath.Join(testDir, "config.yaml")
|
||||
if err := os.WriteFile(configFile, configContent, 0644); err != nil {
|
||||
t.Fatalf("failed to write test config: %v", err)
|
||||
}
|
||||
|
||||
if err := loadConfigWithDefaults(configFile, true); err != nil {
|
||||
t.Fatalf("error loading config file: %v", err)
|
||||
}
|
||||
|
||||
if len(Config.Http.TrustedHeadersArray) != 1 || Config.Http.TrustedHeadersArray[0] != "X-Forwarded-For" {
|
||||
t.Fatalf("expected trusted headers to contain X-Forwarded-For, got %v", Config.Http.TrustedHeadersArray)
|
||||
}
|
||||
if !Config.Http.DisableRateLimit {
|
||||
t.Fatal("expected http.disableRateLimit to be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigLoadSpecificValues(t *testing.T) {
|
||||
// Create isolated test directory
|
||||
testDir := t.TempDir()
|
||||
|
||||
@@ -49,8 +49,8 @@ type Environment struct {
|
||||
type Server struct {
|
||||
MinSearchLength int `json:"minSearchLength" yaml:"minSearchLength"` // minimum length of search query to begin searching (default: 3)
|
||||
DisableUpdateCheck bool `json:"disableUpdateCheck"` // disables backend update check service
|
||||
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is number of cpu cores available.
|
||||
Socket string `json:"socket"` // socket to listen on
|
||||
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is 4.
|
||||
Socket string `json:"socket"` // socket to listen on - eg. /var/run/filebrowser.sock
|
||||
TLSKey string `json:"tlsKey"` // path to TLS key
|
||||
TLSCert string `json:"tlsCert"` // path to TLS cert
|
||||
DisablePreviews bool `json:"disablePreviews"` // disable all previews thumbnails, simple icons will be used
|
||||
|
||||
@@ -57,6 +57,8 @@ type FileOptions struct {
|
||||
ExtractEmbeddedSubtitles bool // whether to extract embedded subtitles from media files
|
||||
AlbumArt bool // whether to get album art from media files
|
||||
ShowHidden bool // whether to show hidden files (true = show, false = hide)
|
||||
ShowPinnedItems bool // whether to show pinned items
|
||||
ShareHash string // when set, pinned items are loaded from this share link
|
||||
HideFileExt string // Hide files based on extensions (eg: '.lrc' or '.srt')
|
||||
FollowSymlinks bool // whether to follow symlinks
|
||||
Only string // whether to only get files or folders
|
||||
@@ -108,4 +110,4 @@ func HideFileByExt(filename, hideExt string) bool {
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@ server:
|
||||
sources:
|
||||
- path: "/srv"
|
||||
auth:
|
||||
key: "change-me-to-a-random-string"
|
||||
totpSecret: "change-me-to-another-random-string"
|
||||
methods:
|
||||
password:
|
||||
enabled: true
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package share
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
)
|
||||
|
||||
// PinnedItems maps share-relative directory paths to pinned item names.
|
||||
type PinnedItems map[string][]string
|
||||
|
||||
// Add records a pinned item name under shareRelDir.
|
||||
func (p PinnedItems) Add(shareRelDir, name string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
items := p[shareRelDir]
|
||||
if slices.Contains(items, name) {
|
||||
return
|
||||
}
|
||||
p[shareRelDir] = append(items, name)
|
||||
}
|
||||
|
||||
// Remove deletes a pinned item name and prunes empty map entries.
|
||||
func (p PinnedItems) Remove(shareRelDir, name string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
items := p[shareRelDir]
|
||||
idx := slices.Index(items, name)
|
||||
if idx < 0 {
|
||||
return
|
||||
}
|
||||
items = append(items[:idx], items[idx+1:]...)
|
||||
if len(items) == 0 {
|
||||
delete(p, shareRelDir)
|
||||
} else {
|
||||
p[shareRelDir] = items
|
||||
}
|
||||
}
|
||||
|
||||
// NamesForDirectory returns pinned item names for a share-relative directory path.
|
||||
func (p PinnedItems) NamesForDirectory(shareRelDir string) []string {
|
||||
if len(p) == 0 {
|
||||
return nil
|
||||
}
|
||||
names := p[shareRelDir]
|
||||
if len(names) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]string, len(names))
|
||||
copy(out, names)
|
||||
return out
|
||||
}
|
||||
|
||||
// EnsurePinnedItems returns a non-nil map for mutation.
|
||||
func (l *Link) EnsurePinnedItems() PinnedItems {
|
||||
if l.PinnedItems == nil {
|
||||
l.PinnedItems = make(PinnedItems)
|
||||
}
|
||||
return l.PinnedItems
|
||||
}
|
||||
|
||||
// ShareRelativeDir maps a source index directory path to a share-relative directory path.
|
||||
// link.Path is the index path of the share root (e.g. "/share/").
|
||||
func (l *Link) ShareRelativeDir(indexDirPath string) (string, error) {
|
||||
shareRootIndex := utils.AddTrailingSlashIfNotExists(l.Path)
|
||||
indexDirPath = utils.AddTrailingSlashIfNotExists(indexDirPath)
|
||||
if !strings.HasPrefix(indexDirPath, shareRootIndex) {
|
||||
return "", fmt.Errorf("path is outside share scope")
|
||||
}
|
||||
|
||||
rel := strings.TrimPrefix(indexDirPath, shareRootIndex)
|
||||
if rel == "" {
|
||||
return "/", nil
|
||||
}
|
||||
return utils.AddTrailingSlashIfNotExists("/" + strings.TrimPrefix(rel, "/")), nil
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package share
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSharePinnedItemsAddRemove(t *testing.T) {
|
||||
p := make(PinnedItems)
|
||||
const dir = "/"
|
||||
const name = "vacation.jpg"
|
||||
|
||||
p.Add(dir, name)
|
||||
if len(p[dir]) != 1 || p[dir][0] != name {
|
||||
t.Fatalf("add failed: %#v", p)
|
||||
}
|
||||
|
||||
p.Add(dir, name)
|
||||
if len(p[dir]) != 1 {
|
||||
t.Fatalf("duplicate add should be ignored: %#v", p)
|
||||
}
|
||||
|
||||
p.Remove(dir, name)
|
||||
if len(p) != 0 {
|
||||
t.Fatalf("remove should prune empty entries: %#v", p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSharePinnedNamesForDirectory(t *testing.T) {
|
||||
p := PinnedItems{
|
||||
"/photos/": {"vacation.jpg", "notes.txt"},
|
||||
}
|
||||
|
||||
names := p.NamesForDirectory("/photos/")
|
||||
if len(names) != 2 || names[0] != "vacation.jpg" || names[1] != "notes.txt" {
|
||||
t.Fatalf("unexpected names: %#v", names)
|
||||
}
|
||||
if got := p.NamesForDirectory("/missing/"); got != nil {
|
||||
t.Fatalf("expected nil for missing directory, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareRelativeDir(t *testing.T) {
|
||||
link := &Link{CommonShare: CommonShare{Path: "/share/"}}
|
||||
|
||||
got, err := link.ShareRelativeDir("/share/")
|
||||
if err != nil {
|
||||
t.Fatalf("ShareRelativeDir root: %v", err)
|
||||
}
|
||||
if got != "/" {
|
||||
t.Fatalf("got %q, want /", got)
|
||||
}
|
||||
|
||||
got, err = link.ShareRelativeDir("/share/test [file2]/")
|
||||
if err != nil {
|
||||
t.Fatalf("ShareRelativeDir subdir: %v", err)
|
||||
}
|
||||
if got != "/test [file2]/" {
|
||||
t.Fatalf("got %q, want /test [file2]/", got)
|
||||
}
|
||||
}
|
||||
@@ -60,11 +60,12 @@ type CreateBody struct {
|
||||
// Link is the information needed to build a shareable link.
|
||||
type Link struct {
|
||||
CommonShare
|
||||
Downloads int `json:"downloads"`
|
||||
Hash string `json:"hash" storm:"id,index"`
|
||||
UserID uint `json:"userID"`
|
||||
Expire int64 `json:"expire"`
|
||||
PasswordHash string `json:"password_hash,omitempty"`
|
||||
Downloads int `json:"downloads"`
|
||||
Hash string `json:"hash" storm:"id,index"`
|
||||
UserID uint `json:"userID"`
|
||||
Expire int64 `json:"expire"`
|
||||
PasswordHash string `json:"password_hash,omitempty"`
|
||||
PinnedItems PinnedItems `json:"pinnedItems,omitempty"`
|
||||
// Token is a random value that will only be set when PasswordHash is set. It is
|
||||
// URL-Safe and is used to download links in password-protected shares via a
|
||||
// query arg.
|
||||
|
||||
@@ -19,13 +19,17 @@ type SearchItem struct {
|
||||
}
|
||||
|
||||
// appendNameGlobSQL adds AND (name GLOB ? OR ...) or AND (name GLOB ? AND ...) when joinAnd is true.
|
||||
func appendNameGlobSQL(query string, args []interface{}, patterns []string, joinAnd bool) (string, []interface{}) {
|
||||
func appendNameGlobSQL(query string, args []interface{}, patterns []string, joinAnd, caseExact bool) (string, []interface{}) {
|
||||
if len(patterns) == 0 {
|
||||
return query, args
|
||||
}
|
||||
nameExpr := "name"
|
||||
if !caseExact {
|
||||
nameExpr = "lower(name)"
|
||||
}
|
||||
parts := make([]string, len(patterns))
|
||||
for i := range patterns {
|
||||
parts[i] = "name GLOB ?"
|
||||
parts[i] = nameExpr + " GLOB ?"
|
||||
args = append(args, patterns[i])
|
||||
}
|
||||
join := " OR "
|
||||
@@ -38,7 +42,7 @@ func appendNameGlobSQL(query string, args []interface{}, patterns []string, join
|
||||
// SearchItems queries the database for items matching the search criteria for a single source.
|
||||
// When nameGlobPatterns is non-empty (and largest is false), rows are restricted with SQLite name GLOB ... OR ....
|
||||
// Returns rows that can be iterated to scan search results.
|
||||
func (db *IndexDB) SearchItems(source string, scope string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd bool) (*sql.Rows, error) {
|
||||
func (db *IndexDB) SearchItems(source string, scope string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd, caseExact bool) (*sql.Rows, error) {
|
||||
query := `
|
||||
SELECT path, name, size, mod_time, type, is_dir, has_preview
|
||||
FROM index_items
|
||||
@@ -54,7 +58,7 @@ func (db *IndexDB) SearchItems(source string, scope string, largest bool, nameGl
|
||||
}
|
||||
|
||||
if !largest && len(nameGlobPatterns) > 0 {
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd)
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd, caseExact)
|
||||
}
|
||||
|
||||
if largest {
|
||||
@@ -67,7 +71,7 @@ func (db *IndexDB) SearchItems(source string, scope string, largest bool, nameGl
|
||||
// SearchItemsMultiSource queries the database for items matching the search criteria across multiple sources.
|
||||
// When nameGlobPatterns is non-empty (and largest is false), restricts rows with SQLite name GLOB ... OR ....
|
||||
// Returns rows that can be iterated to scan search results.
|
||||
func (db *IndexDB) SearchItemsMultiSource(sources []string, sourceScopes map[string]string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd bool) (*sql.Rows, error) {
|
||||
func (db *IndexDB) SearchItemsMultiSource(sources []string, sourceScopes map[string]string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd, caseExact bool) (*sql.Rows, error) {
|
||||
if len(sources) == 0 {
|
||||
return nil, fmt.Errorf("at least one source is required")
|
||||
}
|
||||
@@ -119,7 +123,7 @@ func (db *IndexDB) SearchItemsMultiSource(sources []string, sourceScopes map[str
|
||||
}
|
||||
|
||||
if !largest && len(nameGlobPatterns) > 0 {
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd)
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd, caseExact)
|
||||
}
|
||||
|
||||
if largest {
|
||||
|
||||
@@ -21,7 +21,7 @@ func (s settingsBackend) Save(set *settings.Settings) error {
|
||||
func (s settingsBackend) GetServer() (*settings.Server, error) {
|
||||
server := &settings.Server{
|
||||
Port: 80,
|
||||
NumImageProcessors: 1,
|
||||
NumImageProcessors: 4,
|
||||
}
|
||||
return server, get(s.db, "server", server)
|
||||
}
|
||||
|
||||
@@ -492,13 +492,13 @@ func TestFilterRestrictedFields(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "all allowed fields",
|
||||
fields: []string{"DarkMode", "OtpEnabled", "Locale", "ViewMode"},
|
||||
expected: []string{"DarkMode", "OtpEnabled", "Locale", "ViewMode"},
|
||||
fields: []string{"DarkMode", "OtpEnabled", "Locale", "ViewMode", "PinnedItems"},
|
||||
expected: []string{"DarkMode", "OtpEnabled", "Locale", "ViewMode", "PinnedItems"},
|
||||
},
|
||||
{
|
||||
name: "mixed allowed and restricted",
|
||||
fields: []string{"DarkMode", "Permissions", "Scopes", "OtpEnabled"},
|
||||
expected: []string{"DarkMode", "OtpEnabled"},
|
||||
fields: []string{"DarkMode", "Permissions", "Scopes", "OtpEnabled", "PinnedItems"},
|
||||
expected: []string{"DarkMode", "OtpEnabled", "PinnedItems"},
|
||||
},
|
||||
{
|
||||
name: "all restricted fields",
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package users
|
||||
|
||||
import "slices"
|
||||
|
||||
// Add records a pinned item name under sourcePath and indexDirPath.
|
||||
func (p PinnedItems) Add(sourcePath, indexDirPath, name string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
if p[sourcePath] == nil {
|
||||
p[sourcePath] = make(map[string][]string)
|
||||
}
|
||||
items := p[sourcePath][indexDirPath]
|
||||
if slices.Contains(items, name) {
|
||||
return
|
||||
}
|
||||
p[sourcePath][indexDirPath] = append(items, name)
|
||||
}
|
||||
|
||||
// Remove deletes a pinned item name and prunes empty map entries.
|
||||
func (p PinnedItems) Remove(sourcePath, indexDirPath, name string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
byDir, ok := p[sourcePath]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
items := byDir[indexDirPath]
|
||||
idx := slices.Index(items, name)
|
||||
if idx < 0 {
|
||||
return
|
||||
}
|
||||
items = append(items[:idx], items[idx+1:]...)
|
||||
if len(items) == 0 {
|
||||
delete(byDir, indexDirPath)
|
||||
} else {
|
||||
byDir[indexDirPath] = items
|
||||
}
|
||||
if len(byDir) == 0 {
|
||||
delete(p, sourcePath)
|
||||
}
|
||||
}
|
||||
|
||||
// PinnedNamesForDirectory returns pinned item names for a source/index directory path.
|
||||
func (u *User) PinnedNamesForDirectory(sourcePath, indexDirPath string) []string {
|
||||
if u == nil || len(u.PinnedItems) == 0 {
|
||||
return nil
|
||||
}
|
||||
byDir, ok := u.PinnedItems[sourcePath]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
names := byDir[indexDirPath]
|
||||
if len(names) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]string, len(names))
|
||||
copy(out, names)
|
||||
return out
|
||||
}
|
||||
|
||||
// EnsurePinnedItems returns a non-nil map for mutation.
|
||||
func (u *User) EnsurePinnedItems() PinnedItems {
|
||||
if u.PinnedItems == nil {
|
||||
u.PinnedItems = make(PinnedItems)
|
||||
}
|
||||
return u.PinnedItems
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package users
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPinnedItemsAddRemove(t *testing.T) {
|
||||
p := make(PinnedItems)
|
||||
const source = "/data/files"
|
||||
const dir = "/photos/"
|
||||
const name = "vacation.jpg"
|
||||
|
||||
p.Add(source, dir, name)
|
||||
if len(p[source][dir]) != 1 || p[source][dir][0] != name {
|
||||
t.Fatalf("add failed: %#v", p)
|
||||
}
|
||||
|
||||
p.Add(source, dir, name)
|
||||
if len(p[source][dir]) != 1 {
|
||||
t.Fatalf("duplicate add should be ignored: %#v", p)
|
||||
}
|
||||
|
||||
p.Remove(source, dir, name)
|
||||
if len(p) != 0 {
|
||||
t.Fatalf("remove should prune empty maps: %#v", p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPinnedNamesForDirectory(t *testing.T) {
|
||||
u := &User{
|
||||
NonAdminEditable: NonAdminEditable{
|
||||
PinnedItems: PinnedItems{
|
||||
"/data/files": {
|
||||
"/photos/": {"vacation.jpg", "notes.txt"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
names := u.PinnedNamesForDirectory("/data/files", "/photos/")
|
||||
if len(names) != 2 || names[0] != "vacation.jpg" || names[1] != "notes.txt" {
|
||||
t.Fatalf("unexpected names: %#v", names)
|
||||
}
|
||||
if got := u.PinnedNamesForDirectory("/missing", "/photos/"); got != nil {
|
||||
t.Fatalf("expected nil for missing source, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPinnedItemsRemoveMissing(t *testing.T) {
|
||||
p := make(PinnedItems)
|
||||
p.Remove("/data/files", "/photos/", "vacation.jpg")
|
||||
if len(p) != 0 {
|
||||
t.Fatalf("remove on empty map should be no-op: %#v", p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPinnedItemsMultipleItems(t *testing.T) {
|
||||
p := make(PinnedItems)
|
||||
const source = "/data/files"
|
||||
const dir = "/photos/"
|
||||
|
||||
p.Add(source, dir, "a.jpg")
|
||||
p.Add(source, dir, "b.jpg")
|
||||
p.Add(source, dir, "c.jpg")
|
||||
|
||||
if len(p[source][dir]) != 3 {
|
||||
t.Fatalf("expected 3 items, got %d", len(p[source][dir]))
|
||||
}
|
||||
|
||||
p.Remove(source, dir, "b.jpg")
|
||||
items := p[source][dir]
|
||||
if len(items) != 2 || items[0] != "a.jpg" || items[1] != "c.jpg" {
|
||||
t.Fatalf("unexpected items after remove: %#v", items)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPinnedItemsMultipleDirectories(t *testing.T) {
|
||||
p := make(PinnedItems)
|
||||
const source = "/data/files"
|
||||
const photosDir = "/photos/"
|
||||
const docsDir = "/docs/"
|
||||
|
||||
p.Add(source, photosDir, "a.jpg")
|
||||
p.Add(source, docsDir, "notes.txt")
|
||||
|
||||
if len(p[source][photosDir]) != 1 || p[source][photosDir][0] != "a.jpg" {
|
||||
t.Fatalf("unexpected photos dir: %#v", p[source][photosDir])
|
||||
}
|
||||
if len(p[source][docsDir]) != 1 || p[source][docsDir][0] != "notes.txt" {
|
||||
t.Fatalf("unexpected docs dir: %#v", p[source][docsDir])
|
||||
}
|
||||
|
||||
p.Remove(source, photosDir, "a.jpg")
|
||||
if _, ok := p[source][photosDir]; ok {
|
||||
t.Fatalf("photos dir should be pruned: %#v", p)
|
||||
}
|
||||
if len(p[source][docsDir]) != 1 {
|
||||
t.Fatalf("docs dir should remain: %#v", p[source][docsDir])
|
||||
}
|
||||
}
|
||||
@@ -96,24 +96,27 @@ type Preview struct {
|
||||
Models bool `json:"models"` // show live thumbnails for 3D models files
|
||||
}
|
||||
|
||||
// source filesystem path -> index directory path -> pinned item names (unique within the directory)
|
||||
type PinnedItems map[string]map[string][]string
|
||||
|
||||
// User describes a persisted account. Scopes and source sidebar links store filesystem paths in Name/SourceName;
|
||||
// JSON responses use display names only (see http prepForFrontend).
|
||||
type User struct {
|
||||
NonAdminEditable
|
||||
DisableSettings bool `json:"disableSettings"`
|
||||
ID uint `storm:"id,increment" json:"id"`
|
||||
Username string `storm:"unique" json:"username"`
|
||||
Scopes []SourceScope `json:"scopes"`
|
||||
Scope string `json:"scope,omitempty"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
Permissions Permissions `json:"permissions"`
|
||||
ApiKeys map[string]AuthToken `json:"apiKeys,omitempty"` // deprecated: use Tokens instead
|
||||
Tokens map[string]AuthToken `json:"tokens,omitempty"`
|
||||
TOTPSecret string `json:"totpSecret,omitempty"`
|
||||
TOTPNonce string `json:"totpNonce,omitempty"`
|
||||
LoginMethod LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"` // true if TOTP is enabled, false otherwise
|
||||
Version int `json:"version"`
|
||||
DisableSettings bool `json:"disableSettings"`
|
||||
ID uint `storm:"id,increment" json:"id"`
|
||||
Username string `storm:"unique" json:"username"`
|
||||
Scopes []SourceScope `json:"scopes"`
|
||||
Scope string `json:"scope,omitempty"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
Permissions Permissions `json:"permissions"`
|
||||
ApiKeys map[string]AuthToken `json:"apiKeys,omitempty"` // deprecated: use Tokens instead
|
||||
Tokens map[string]AuthToken `json:"tokens,omitempty"`
|
||||
TOTPSecret string `json:"totpSecret,omitempty"`
|
||||
TOTPNonce string `json:"totpNonce,omitempty"`
|
||||
LoginMethod LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"` // true if TOTP is enabled, false otherwise
|
||||
Version int `json:"version"`
|
||||
// legacy for migration purposes... og filebrowser has perm attribute
|
||||
Perm Permissions `json:"perm,omitzero"` // deprecated: use Permissions instead
|
||||
}
|
||||
@@ -125,43 +128,44 @@ type SourceScope struct {
|
||||
|
||||
// json tags must match variable name with smaller case first letter
|
||||
type NonAdminEditable struct {
|
||||
EditorQuickSave bool `json:"editorQuickSave"` // show quick save button in editor
|
||||
HideSidebarFileActions bool `json:"hideSidebarFileActions"` // hide the file actions in the sidebar
|
||||
DisableQuickToggles bool `json:"disableQuickToggles"` // disable the quick toggles in the sidebar
|
||||
DisableSearchOptions bool `json:"disableSearchOptions"` // disable the search options in the search bar
|
||||
DeleteWithoutConfirming bool `json:"deleteWithoutConfirming"` // delete files without confirmation
|
||||
Preview Preview `json:"preview"`
|
||||
StickySidebar bool `json:"stickySidebar"` // keep sidebar open when navigating
|
||||
DarkMode bool `json:"darkMode"` // should dark mode be enabled
|
||||
Password string `json:"password,omitempty"`
|
||||
Locale string `json:"locale"` // language to use: eg. de, en, or fr
|
||||
ViewMode string `json:"viewMode"` // view mode to use: eg. normal, list, grid, or compact
|
||||
SingleClick bool `json:"singleClick"` // open directory on single click, also enables middle click to open in new tab
|
||||
Sorting Sorting `json:"sorting"`
|
||||
ShowHidden bool `json:"showHidden"` // show hidden files in the UI. On windows this includes files starting with a dot and windows hidden files
|
||||
HideFileExt string `json:"hideFileExt"` // space separated list of file extensions to hide in UI and API
|
||||
DateFormat bool `json:"dateFormat"` // when false, the date is relative, when true, the date is an exact timestamp
|
||||
GallerySize int `json:"gallerySize"` // 0-9 - the size of the gallery thumbnails
|
||||
ThemeColor string `json:"themeColor"` // theme color to use: eg. #ff0000, or var(--red), var(--purple), etc
|
||||
QuickDownload bool `json:"quickDownload"` // show icon to download in one click
|
||||
DisableUpdateNotifications bool `json:"disableUpdateNotifications"` // disable update notifications
|
||||
FileLoading FileLoading `json:"fileLoading"` // upload and download settings
|
||||
DisableOfficePreviewExt string `json:"disableOfficePreviewExt"` // deprecated
|
||||
DisableOnlyOfficeExt string `json:"disableOnlyOfficeExt"` // deprecated
|
||||
DisablePreviewExt string `json:"disablePreviewExt"` // space separated list of file extensions to disable preview for
|
||||
DisableViewingExt string `json:"disableViewingExt"` // space separated list of file extensions to disable viewing for
|
||||
CustomTheme string `json:"customTheme"` // Name of theme to use chosen from custom themes config.
|
||||
ShowSelectMultiple bool `json:"showSelectMultiple"` // show select multiple files on desktop
|
||||
ShowCopyPath bool `json:"showCopyPath"` // show copy path action in the context menu
|
||||
ShowToolsInSidebar bool `json:"showToolsInSidebar"` // when false, sidebar hides links with category "tool" (default: true)
|
||||
DebugOffice bool `json:"debugOffice"` // debug onlyoffice editor
|
||||
OtpEnabled bool `json:"otpEnabled"` // allow non-admin users to disable their own OTP
|
||||
SidebarLinks []SidebarLink `json:"sidebarLinks"` // customizable sidebar links
|
||||
HideFilesInTree bool `json:"hideFilesInTree"` // hide files in the sidebar tree navigation, when true, will show only directories.
|
||||
DeleteAfterArchive bool `json:"deleteAfterArchive"` // delete source files after successful creation/extraction of archives
|
||||
PreferEditorForMarkdown bool `json:"preferEditorForMarkdown"` // prefer editor first for markdown files instead of the Markdown Viewer
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
PasskeyCredentials []WebAuthnCredential `json:"passkeyCredentials,omitempty"`
|
||||
EditorQuickSave bool `json:"editorQuickSave"` // show quick save button in editor
|
||||
HideSidebarFileActions bool `json:"hideSidebarFileActions"` // hide the file actions in the sidebar
|
||||
DisableQuickToggles bool `json:"disableQuickToggles"` // disable the quick toggles in the sidebar
|
||||
DisableSearchOptions bool `json:"disableSearchOptions"` // disable the search options in the search bar
|
||||
DeleteWithoutConfirming bool `json:"deleteWithoutConfirming"` // delete files without confirmation
|
||||
Preview Preview `json:"preview"`
|
||||
StickySidebar bool `json:"stickySidebar"` // keep sidebar open when navigating
|
||||
DarkMode bool `json:"darkMode"` // should dark mode be enabled
|
||||
Password string `json:"password,omitempty"`
|
||||
Locale string `json:"locale"` // language to use: eg. de, en, or fr
|
||||
ViewMode string `json:"viewMode"` // view mode to use: eg. normal, list, grid, or compact
|
||||
SingleClick bool `json:"singleClick"` // open directory on single click, also enables middle click to open in new tab
|
||||
Sorting Sorting `json:"sorting"`
|
||||
ShowHidden bool `json:"showHidden"` // show hidden files in the UI. On windows this includes files starting with a dot and windows hidden files
|
||||
HideFileExt string `json:"hideFileExt"` // space separated list of file extensions to hide in UI and API
|
||||
DateFormat bool `json:"dateFormat"` // when false, the date is relative, when true, the date is an exact timestamp
|
||||
GallerySize int `json:"gallerySize"` // 0-9 - the size of the gallery thumbnails
|
||||
ThemeColor string `json:"themeColor"` // theme color to use: eg. #ff0000, or var(--red), var(--purple), etc
|
||||
QuickDownload bool `json:"quickDownload"` // show icon to download in one click
|
||||
DisableUpdateNotifications bool `json:"disableUpdateNotifications"` // disable update notifications
|
||||
FileLoading FileLoading `json:"fileLoading"` // upload and download settings
|
||||
DisableOfficePreviewExt string `json:"disableOfficePreviewExt"` // deprecated
|
||||
DisableOnlyOfficeExt string `json:"disableOnlyOfficeExt"` // deprecated
|
||||
DisablePreviewExt string `json:"disablePreviewExt"` // space separated list of file extensions to disable preview for
|
||||
DisableViewingExt string `json:"disableViewingExt"` // space separated list of file extensions to disable viewing for
|
||||
CustomTheme string `json:"customTheme"` // Name of theme to use chosen from custom themes config.
|
||||
ShowSelectMultiple bool `json:"showSelectMultiple"` // show select multiple files on desktop
|
||||
ShowCopyPath bool `json:"showCopyPath"` // show copy path action in the context menu
|
||||
ShowToolsInSidebar bool `json:"showToolsInSidebar"` // when false, sidebar hides links with category "tool" (default: true)
|
||||
DebugOffice bool `json:"debugOffice"` // debug onlyoffice editor
|
||||
OtpEnabled bool `json:"otpEnabled"` // allow non-admin users to disable their own OTP
|
||||
SidebarLinks []SidebarLink `json:"sidebarLinks"` // customizable sidebar links
|
||||
HideFilesInTree bool `json:"hideFilesInTree"` // hide files in the sidebar tree navigation, when true, will show only directories.
|
||||
DeleteAfterArchive bool `json:"deleteAfterArchive"` // delete source files after successful creation/extraction of archives
|
||||
PreferEditorForMarkdown bool `json:"preferEditorForMarkdown"` // prefer editor first for markdown files instead of the Markdown Viewer
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
PasskeyCredentials []WebAuthnCredential `json:"passkeyCredentials,omitempty"`
|
||||
PinnedItems PinnedItems `json:"pinnedItems,omitempty"`
|
||||
}
|
||||
|
||||
type FileLoading struct {
|
||||
|
||||
+34
-35
@@ -4,36 +4,36 @@ go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/asdine/storm/v3 v3.2.1
|
||||
github.com/coreos/go-oidc/v3 v3.18.0
|
||||
github.com/coreos/go-oidc/v3 v3.20.0
|
||||
github.com/coreos/go-systemd/v22 v22.7.0
|
||||
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
|
||||
github.com/dsoprea/go-exif/v3 v3.0.1
|
||||
github.com/gen2brain/go-fitz v1.24.15
|
||||
github.com/go-ldap/ldap/v3 v3.4.13
|
||||
github.com/go-playground/validator/v10 v10.30.2
|
||||
github.com/go-webauthn/webauthn v0.17.3
|
||||
github.com/gen2brain/go-fitz v1.28.2
|
||||
github.com/go-ldap/ldap/v3 v3.4.14
|
||||
github.com/go-playground/validator/v10 v10.30.3
|
||||
github.com/go-webauthn/webauthn v0.17.4
|
||||
github.com/goccy/go-yaml v1.19.2
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/gtsteffaniak/go-cache v1.1.0
|
||||
github.com/gtsteffaniak/go-logger v1.1.0
|
||||
github.com/kovidgoyal/imaging v1.8.21
|
||||
github.com/mattn/go-sqlite3 v1.14.44
|
||||
github.com/kovidgoyal/imaging v1.8.23
|
||||
github.com/mattn/go-sqlite3 v1.14.48
|
||||
github.com/pquerna/otp v1.5.0
|
||||
github.com/spf13/afero v1.15.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/swaggo/http-swagger v1.3.4
|
||||
github.com/swaggo/swag v1.16.6
|
||||
golang.org/x/crypto v0.51.0
|
||||
golang.org/x/image v0.40.0
|
||||
golang.org/x/mod v0.36.0
|
||||
golang.org/x/net v0.54.0
|
||||
golang.org/x/crypto v0.54.0
|
||||
golang.org/x/image v0.44.0
|
||||
golang.org/x/mod v0.38.0
|
||||
golang.org/x/net v0.57.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sys v0.44.0
|
||||
golang.org/x/sys v0.47.0
|
||||
golang.org/x/time v0.15.0
|
||||
golang.org/x/tools v0.45.0
|
||||
golang.org/x/tools v0.48.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
modernc.org/sqlite v1.50.1
|
||||
modernc.org/sqlite v1.54.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -60,7 +60,7 @@ require (
|
||||
github.com/Masterminds/semver/v3 v3.5.0 // indirect
|
||||
github.com/MirrexOne/unqueryvet v1.5.4 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
|
||||
github.com/air-verse/air v1.65.1 // indirect
|
||||
github.com/air-verse/air v1.65.3 // indirect
|
||||
github.com/alecthomas/chroma/v2 v2.24.1 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
|
||||
@@ -106,7 +106,7 @@ require (
|
||||
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/ebitengine/purego v0.10.0 // indirect
|
||||
github.com/ebitengine/purego v0.10.1 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/fatih/color v1.19.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
@@ -116,20 +116,20 @@ require (
|
||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/ghostiam/protogetter v0.3.20 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
||||
github.com/go-critic/go-critic v0.14.3 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.23.1 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.5 // indirect
|
||||
github.com/go-openapi/spec v0.22.4 // indirect
|
||||
github.com/go-openapi/swag/conv v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/jsonutils v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/loading v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/stringutils v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/typeutils v0.26.0 // indirect
|
||||
github.com/go-openapi/swag/yamlutils v0.26.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v1.0.0 // indirect
|
||||
github.com/go-openapi/jsonreference v1.0.0 // indirect
|
||||
github.com/go-openapi/spec v0.22.6 // indirect
|
||||
github.com/go-openapi/swag/conv v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/jsonutils v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/loading v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/stringutils v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/typeutils v0.27.0 // indirect
|
||||
github.com/go-openapi/swag/yamlutils v0.27.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
@@ -140,14 +140,14 @@ require (
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
github.com/go-webauthn/x v0.2.5 // indirect
|
||||
github.com/go-webauthn/x v0.2.6 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/godoc-lint/godoc-lint v0.11.2 // indirect
|
||||
github.com/gofrs/flock v0.13.0 // indirect
|
||||
github.com/gohugoio/hugo v0.149.1 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
|
||||
github.com/golang/geo v0.0.0-20260512202753-e3c51de6d1b6 // indirect
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golangci/asciicheck v0.5.0 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 // indirect
|
||||
@@ -178,7 +178,6 @@ require (
|
||||
github.com/jjti/go-spancheck v0.6.5 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/julz/importas v0.2.0 // indirect
|
||||
github.com/jupiterrider/ffi v0.7.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect
|
||||
github.com/kisielk/errcheck v1.10.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
|
||||
@@ -205,7 +204,7 @@ require (
|
||||
github.com/maratori/testpackage v1.1.2 // indirect
|
||||
github.com/matoous/godox v1.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/mattn/go-isatty v0.0.23 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.23 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgechev/revive v1.15.0 // indirect
|
||||
@@ -282,19 +281,19 @@ require (
|
||||
go-simpler.org/sloglint v0.12.0 // indirect
|
||||
go.augendre.info/arangolint v0.4.0 // indirect
|
||||
go.augendre.info/fatcontext v0.9.0 // indirect
|
||||
go.etcd.io/bbolt v1.4.3 // indirect
|
||||
go.etcd.io/bbolt v1.5.0 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
golang.org/x/sync v0.22.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
honnef.co/go/tools v0.7.0 // indirect
|
||||
modernc.org/libc v1.72.3 // indirect
|
||||
modernc.org/libc v1.74.2 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
mvdan.cc/gofumpt v0.9.2 // indirect
|
||||
|
||||
+80
-82
@@ -85,8 +85,8 @@ github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsu
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863 h1:BRrxwOZBolJN4gIwvZMJY1tzqBvQgpaZiQRuIDD40jM=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
|
||||
github.com/air-verse/air v1.65.1 h1:G4hy4YemKrIcGAvYMor+86PhxdtBEq0n9ebJ4RoYy8w=
|
||||
github.com/air-verse/air v1.65.1/go.mod h1:OaJZSfZqf7wyjS2oP/CcEVyIt0JmZuPh5x1gdtklmmY=
|
||||
github.com/air-verse/air v1.65.3 h1:7NUAqofZuSf5vZbVoZpdTr/4LuKkOCj1JTiMrOdUs7A=
|
||||
github.com/air-verse/air v1.65.3/go.mod h1:OaJZSfZqf7wyjS2oP/CcEVyIt0JmZuPh5x1gdtklmmY=
|
||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/chroma/v2 v2.24.1 h1:m5ffpfZbIb++k8AqFEKy9uVgY12xIQtBsQlc6DfZJQM=
|
||||
@@ -211,8 +211,8 @@ github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/go-oidc/v3 v3.18.0 h1:V9orjXynvu5wiC9SemFTWnG4F45v403aIcjWo0d41+A=
|
||||
github.com/coreos/go-oidc/v3 v3.18.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0 h1:EtE0WIBHk03N+DqGkY4+UONzzZHk7amKt6IyNd7OsZE=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
@@ -256,8 +256,8 @@ github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=
|
||||
github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=
|
||||
github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
@@ -283,16 +283,16 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
|
||||
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gen2brain/go-fitz v1.24.15 h1:sJNB1MOWkqnzzENPHggFpgxTwW0+S5WF/rM5wUBpJWo=
|
||||
github.com/gen2brain/go-fitz v1.24.15/go.mod h1:SftkiVbTHqF141DuiLwBBM65zP7ig6AVDQpf2WlHamo=
|
||||
github.com/gen2brain/go-fitz v1.28.2 h1:845G85N5TUgnq5oDqyYrW0JvehAkeo35UkkK2dJtW1M=
|
||||
github.com/gen2brain/go-fitz v1.28.2/go.mod h1:pY2hqAjp9Zy7qfPI2gwbJMHBFAdZpVXOLrRxD82l3Bs=
|
||||
github.com/getkin/kin-openapi v0.133.0 h1:pJdmNohVIJ97r4AUFtEXRXwESr8b0bD721u/Tz6k8PQ=
|
||||
github.com/getkin/kin-openapi v0.133.0/go.mod h1:boAciF6cXk5FhPqe/NQeBTeenbjqU4LhWBf09ILVvWE=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0=
|
||||
github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoMML7iQ=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-critic/go-critic v0.14.3 h1:5R1qH2iFeo4I/RJU8vTezdqs08Egi4u5p6vOESA0pog=
|
||||
github.com/go-critic/go-critic v0.14.3/go.mod h1:xwntfW6SYAd7h1OqDzmN6hBX/JxsEKl5up/Y2bsxgVQ=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
@@ -309,48 +309,48 @@ github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-ldap/ldap/v3 v3.4.13 h1:+x1nG9h+MZN7h/lUi5Q3UZ0fJ1GyDQYbPvbuH38baDQ=
|
||||
github.com/go-ldap/ldap/v3 v3.4.13/go.mod h1:LxsGZV6vbaK0sIvYfsv47rfh4ca0JXokCoKjZxsszv0=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14 h1:D6PYdEgsaVzsXyr6w/yDC06Ria4uUhWm+Rb+er8lfAs=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14/go.mod h1:S4eJUMUNjDkE0ZJtIZdybwyb03sGGLW6gxXT1Hs8VKA=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4=
|
||||
github.com/go-openapi/jsonpointer v0.23.1/go.mod h1:iWRmZTrGn7XwYhtPt/fvdSFj1OfNBngqRT2UG3BxSqY=
|
||||
github.com/go-openapi/jsonreference v0.21.5 h1:6uCGVXU/aNF13AQNggxfysJ+5ZcU4nEAe+pJyVWRdiE=
|
||||
github.com/go-openapi/jsonreference v0.21.5/go.mod h1:u25Bw85sX4E2jzFodh1FOKMTZLcfifd1Q+iKKOUxExw=
|
||||
github.com/go-openapi/spec v0.22.4 h1:4pxGjipMKu0FzFiu/DPwN3CTBRlVM2yLf/YTWorYfDQ=
|
||||
github.com/go-openapi/spec v0.22.4/go.mod h1:WQ6Ai0VPWMZgMT4XySjlRIE6GP1bGQOtEThn3gcWLtQ=
|
||||
github.com/go-openapi/jsonpointer v1.0.0 h1:kR9tHqY0CtZaOPVFm622dPVNhrvYpwr4uCxgL3h1H8s=
|
||||
github.com/go-openapi/jsonpointer v1.0.0/go.mod h1:Z3rw7dWu1p9IgitXCFamSlA5lmDiklEB6vkaxcNZW5Y=
|
||||
github.com/go-openapi/jsonreference v1.0.0 h1:jlmTr6torcd1YgDQvSfNmRtKzYDO4FGBkrAdlAVWnpY=
|
||||
github.com/go-openapi/jsonreference v1.0.0/go.mod h1:jtwdyGbJk0Xhe5Y+rwtglQP6Sb1WZST4rT32LWB+sv0=
|
||||
github.com/go-openapi/spec v0.22.6 h1:Tyy1pLaNCM8GBCFLoGYLonjJi6zykqyLCjXLc19ZPic=
|
||||
github.com/go-openapi/spec v0.22.6/go.mod h1:HZvTHat+iH0PALQRWhrqIHtU/PEqxqd89fu0MxGlMeM=
|
||||
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
|
||||
github.com/go-openapi/swag/conv v0.26.0 h1:5yGGsPYI1ZCva93U0AoKi/iZrNhaJEjr324YVsiD89I=
|
||||
github.com/go-openapi/swag/conv v0.26.0/go.mod h1:tpAmIL7X58VPnHHiSO4uE3jBeRamGsFsfdDeDtb5ECE=
|
||||
github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w=
|
||||
github.com/go-openapi/swag/jsonname v0.26.0/go.mod h1:urBBR8bZNoDYGr653ynhIx+gTeIz0ARZxHkAPktJK2M=
|
||||
github.com/go-openapi/swag/jsonutils v0.26.0 h1:FawFML2iAXsPqmERscuMPIHmFsoP1tOqWkxBaKNMsnA=
|
||||
github.com/go-openapi/swag/jsonutils v0.26.0/go.mod h1:2VmA0CJlyFqgawOaPI9psnjFDqzyivIqLYN34t9p91E=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.26.0 h1:apqeINu/ICHouqiRZbyFvuDge5jCmmLTqGQ9V95EaOM=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.26.0/go.mod h1:AyM6QT8uz5IdKxk5akv0y6u4QvcL9GWERt0Jx/F/R8Y=
|
||||
github.com/go-openapi/swag/loading v0.26.0 h1:Apg6zaKhCJurpJer0DCxq99qwmhFddBhaMX7kilDcko=
|
||||
github.com/go-openapi/swag/loading v0.26.0/go.mod h1:dBxQ/6V2uBaAQdevN18VELE6xSpJWZxLX4txe12JwDg=
|
||||
github.com/go-openapi/swag/stringutils v0.26.0 h1:qZQngLxs5s7SLijc3N2ZO+fUq2o8LjuWAASSrJuh+xg=
|
||||
github.com/go-openapi/swag/stringutils v0.26.0/go.mod h1:sWn5uY+QIIspwPhvgnqJsH8xqFT2ZbYcvbcFanRyhFE=
|
||||
github.com/go-openapi/swag/typeutils v0.26.0 h1:2kdEwdiNWy+JJdOvu5MA2IIg2SylWAFuuyQIKYybfq4=
|
||||
github.com/go-openapi/swag/typeutils v0.26.0/go.mod h1:oovDuIUvTrEHVMqWilQzKzV4YlSKgyZmFh7AlfABNVE=
|
||||
github.com/go-openapi/swag/yamlutils v0.26.0 h1:H7O8l/8NJJQ/oiReEN+oMpnGMyt8G0hl460nRZxhLMQ=
|
||||
github.com/go-openapi/swag/yamlutils v0.26.0/go.mod h1:1evKEGAtP37Pkwcc7EWMF0hedX0/x3Rkvei2wtG/TbU=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.4.2 h1:5zRca5jw7lzVREKCZVNBpysDNBjj74rBh0N2BGQbSR0=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.4.2/go.mod h1:XVevPw5hUXuV+5AkI1u1PeAm27EQVrhXTTCPAF85LmE=
|
||||
github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLuq0ePx4=
|
||||
github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
|
||||
github.com/go-openapi/swag/conv v0.27.0 h1:EKOH4feXrvdo8DbSsXSAqRT8fz1epEnS5O2IfXUOzE8=
|
||||
github.com/go-openapi/swag/conv v0.27.0/go.mod h1:pfiv0uKQTbaGApk8Zs/lZV3uSjmSpa2FO1y183YngN8=
|
||||
github.com/go-openapi/swag/jsonname v0.27.0 h1:4QVB//CKOdE8IOiBg19JNY2wfDS48MhesIquYBy2rUE=
|
||||
github.com/go-openapi/swag/jsonname v0.27.0/go.mod h1:I1YsyvvhBuZsFXSW6I7ODfdyq13p7hDil//1T9/pFFk=
|
||||
github.com/go-openapi/swag/jsonutils v0.27.0 h1:VYtd9jEQYeU4j8q5vdn5KWotF4vKywhGdMBrALtAsfE=
|
||||
github.com/go-openapi/swag/jsonutils v0.27.0/go.mod h1:U7pb8AGuwhok3RDicHeHwSG4L3PXSq6PAL98Aon632g=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.0 h1:+d7C7Ur/SsGg/UZ9G0JEovnfRqtMNZCJQGKc2h/ojoE=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.0/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY=
|
||||
github.com/go-openapi/swag/loading v0.27.0 h1:s8DA9aPEdFH6OluHUYUn3DnIuoTdyWs9RwffXBUfyeI=
|
||||
github.com/go-openapi/swag/loading v0.27.0/go.mod h1:VOz+Jg6UGGywcmRvYsI4fvtp+bd7NfioseGEPleYdA4=
|
||||
github.com/go-openapi/swag/stringutils v0.27.0 h1:Of7w/HljWsNZvuxsUAnw3n+hCOyI6HLJOxW2kQRAxio=
|
||||
github.com/go-openapi/swag/stringutils v0.27.0/go.mod h1:lzRN95CxXmA03XcDWHLOb6nOMcxCqR5rGY0lOgsfRoM=
|
||||
github.com/go-openapi/swag/typeutils v0.27.0 h1:aCf4MSGo8NLwZP8Q6t32DWLJSvl/WwNqgmEG+xJ6v2o=
|
||||
github.com/go-openapi/swag/typeutils v0.27.0/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ=
|
||||
github.com/go-openapi/swag/yamlutils v0.27.0 h1:bQ6eAMil5X9tdcf7dMn4t15alzG6jddnrKPuKa/zxKM=
|
||||
github.com/go-openapi/swag/yamlutils v0.27.0/go.mod h1:yRfIo7qqVkmJRQjX8exjA3AfcI8rH1KDNPsTparoCv4=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.6.0 h1:gGHwAJ0R/5jU8BEGDbfRNR3hL68dAVi84WuOApp29B0=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.6.0/go.mod h1:tY+St1SGq4NFl0QIqdTY4aEdbChAHxhyB77XQi9iJCo=
|
||||
github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug=
|
||||
github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.30.2 h1:JiFIMtSSHb2/XBUbWM4i/MpeQm9ZK2xqPNk8vgvu5JQ=
|
||||
github.com/go-playground/validator/v10 v10.30.2/go.mod h1:mAf2pIOVXjTEBrwUMGKkCWKKPs9NheYGabeB04txQSc=
|
||||
github.com/go-playground/validator/v10 v10.30.3 h1:4MU6YkEwx7GbcPJOZxrtbu+QfF3pJLJuaYTeAH0DYy8=
|
||||
github.com/go-playground/validator/v10 v10.30.3/go.mod h1:4Axh7oCNGcoGkqLoE4YWt6n20mcEIsPRlB7vPk3lpyc=
|
||||
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
|
||||
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
@@ -377,10 +377,10 @@ github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUN
|
||||
github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig=
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/go-webauthn/webauthn v0.17.3 h1:XHZ0TXV7k8vChcE4TFgPitOPJ5cb7h1dpAeFDS0cjCo=
|
||||
github.com/go-webauthn/webauthn v0.17.3/go.mod h1:PlkMgmuL9McCT7dvgBj/Sz/fgs3V6ZID6/KnFkEcPvQ=
|
||||
github.com/go-webauthn/x v0.2.5 h1:wEVTfU04XFyPTXGQbKOQwMKhcDWfDAkdsDDBsDaG9yY=
|
||||
github.com/go-webauthn/x v0.2.5/go.mod h1:Qna/yJz9rV6lRzwl5BfYbmTJpVGxcBIds3gJtw2tlGg=
|
||||
github.com/go-webauthn/webauthn v0.17.4 h1:KFTSz3R2RYDiUn/0cDi3XTJgFenSG74eKTTHlqWhlxk=
|
||||
github.com/go-webauthn/webauthn v0.17.4/go.mod h1:pZk63EE/BdztlmyS4Yc+9H5g4a8blNlbtGmdHQHbZX8=
|
||||
github.com/go-webauthn/x v0.2.6 h1:TEyDuQAIiEgYpx60nKiBJIX/5nSUC8LxNbH+uf5U9uk=
|
||||
github.com/go-webauthn/x v0.2.6/go.mod h1:45bA7YEqyQhRcQJ/TiBb46Ww8yqHBGvgEhQ3WWF0aDo=
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY=
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM=
|
||||
github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4=
|
||||
@@ -417,8 +417,8 @@ github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArs
|
||||
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-20260512202753-e3c51de6d1b6 h1:maAhA7cpighmEi96eTgDdmlhwnHYEgwhR6t+T7k3Png=
|
||||
github.com/golang/geo v0.0.0-20260512202753-e3c51de6d1b6/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8=
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641 h1:cpoobkgVGCE6bC5kJkOfwfM6hAtZuvoBjnCLECxG4AU=
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
@@ -585,8 +585,6 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ=
|
||||
github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY=
|
||||
github.com/jupiterrider/ffi v0.7.0 h1:RKsl6Ascal+3kyAqR5Qcbp83LceQMLc1VZbPfHWoNzs=
|
||||
github.com/jupiterrider/ffi v0.7.0/go.mod h1:9dauhpOfNqrqk28fxuu0kkdeFtT9Qr4vbfigiuIXN7c=
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0=
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY=
|
||||
github.com/kisielk/errcheck v1.10.0 h1:Lvs/YAHP24YKg08LA8oDw2z9fJVme090RAXd90S+rrw=
|
||||
@@ -600,8 +598,8 @@ github.com/kovidgoyal/go-parallel v1.1.1 h1:1OzpNjtrUkBPq3UaqrnvOoB2F9RttSt811ui
|
||||
github.com/kovidgoyal/go-parallel v1.1.1/go.mod h1:BJNIbe6+hxyFWv7n6oEDPj3PA5qSw5OCtf0hcVxWJiw=
|
||||
github.com/kovidgoyal/go-shm v1.0.0 h1:HJEel9D1F9YhULvClEHJLawoRSj/1u/EDV7MJbBPgQo=
|
||||
github.com/kovidgoyal/go-shm v1.0.0/go.mod h1:Yzb80Xf9L3kaoB2RGok9hHwMIt7Oif61kT6t3+VnZds=
|
||||
github.com/kovidgoyal/imaging v1.8.21 h1:95S2+dowTeKJJHNpf6lnScvIennTr2H0zQotu+ptNQw=
|
||||
github.com/kovidgoyal/imaging v1.8.21/go.mod h1:976F+zjiQeZ7sd87Pxlm0a64S/w9bImSIWg3sSk1rdQ=
|
||||
github.com/kovidgoyal/imaging v1.8.23 h1:4WsboyQ/E8tic2kX49P93Rvscg33SPsCwTBG5EZZF54=
|
||||
github.com/kovidgoyal/imaging v1.8.23/go.mod h1:k3Iot3H0v2rSWXIxQISfT3e9wIryqzAHLHCuhG7z9lM=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
@@ -660,12 +658,12 @@ github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-isatty v0.0.23 h1:cYwCQTQf3HB6xUC+BtyCLZNr7IzbOmoZbmssVNzSyiQ=
|
||||
github.com/mattn/go-isatty v0.0.23/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
|
||||
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mattn/go-sqlite3 v1.14.44 h1:3VSe+xafpbzsLbdr2AWlAZk9yRHiBhTBakioXaCKTF8=
|
||||
github.com/mattn/go-sqlite3 v1.14.44/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
|
||||
github.com/mattn/go-sqlite3 v1.14.48 h1:7XHIgl0a8HwOaiK4E47ozLkST78rR9+OtNGx27D/TFs=
|
||||
github.com/mattn/go-sqlite3 v1.14.48/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mgechev/revive v1.15.0 h1:vJ0HzSBzfNyPbHKolgiFjHxLek9KUijhqh42yGoqZ8Q=
|
||||
@@ -928,8 +926,8 @@ go.augendre.info/arangolint v0.4.0/go.mod h1:l+f/b4plABuFISuKnTGD4RioXiCCgghv2xq
|
||||
go.augendre.info/fatcontext v0.9.0 h1:Gt5jGD4Zcj8CDMVzjOJITlSb9cEch54hjRRlN3qDojE=
|
||||
go.augendre.info/fatcontext v0.9.0/go.mod h1:L94brOAT1OOUNue6ph/2HnwxoNlds9aXDF2FcUntbNw=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
||||
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
|
||||
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
@@ -952,8 +950,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
|
||||
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -972,8 +970,8 @@ golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 h1:qWFG1Dj7TBjOjO
|
||||
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.40.0 h1:Tw4GyDXMo+daZN1znreBRC3VayR1aLFUyUEOLUdW1a8=
|
||||
golang.org/x/image v0.40.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA=
|
||||
golang.org/x/image v0.44.0 h1:+tDekMZED9+LrtB3G5xzRggpVh9CARjZqROla3R3R+I=
|
||||
golang.org/x/image v0.44.0/go.mod h1:V8K3KE9KKKE+pLpQDOeN18w9oacNSvy1tDOirTu4xtY=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -996,8 +994,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4=
|
||||
golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ=
|
||||
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
|
||||
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1036,8 +1034,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
|
||||
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1059,8 +1057,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1107,8 +1105,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
|
||||
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
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=
|
||||
@@ -1120,8 +1118,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/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.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -1174,8 +1172,8 @@ golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0t
|
||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8=
|
||||
golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0=
|
||||
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
|
||||
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
|
||||
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
|
||||
@@ -1292,20 +1290,20 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=
|
||||
honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc=
|
||||
modernc.org/cc/v4 v4.28.2 h1:3tQ0lf2ADtoby2EtSP+J7IE2SHwEJdP8ioR59wx7XpY=
|
||||
modernc.org/cc/v4 v4.28.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ=
|
||||
modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A=
|
||||
modernc.org/cc/v4 v4.29.1 h1:MKgdCV3WykTSPqpVrnxdEDS0HEd2FHpKZDzxzU5LyeI=
|
||||
modernc.org/cc/v4 v4.29.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
|
||||
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
|
||||
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
|
||||
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.72.3 h1:ZnDF4tXn4NBXFutMMQC4vtbTFSXhhKzR73fv0beZEAU=
|
||||
modernc.org/libc v1.72.3/go.mod h1:dn0dZNnnn1clLyvRxLxYExxiKRZIRENOfqQ8XEeg4Qs=
|
||||
modernc.org/libc v1.74.2 h1:r94QPC+Mh3WN1lSCDxQxFdIxcI+zdQROo+1pTEZGqkk=
|
||||
modernc.org/libc v1.74.2/go.mod h1:4H7h/MJ8wnjL8RAbp9v3OXgnk22X7MouHIhDbvP3gj4=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
@@ -1314,8 +1312,8 @@ modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.50.1 h1:l+cQvn0sd0zJJtfygGHuQJ5AjlrwXmWPw4KP3ZMwr9w=
|
||||
modernc.org/sqlite v1.50.1/go.mod h1:tcNzv5p84E0skkmJn038y+hWJbLQXQqEnQfeh5r2JLM=
|
||||
modernc.org/sqlite v1.54.0 h1:JCxR4qwkJvOaqAoYcgDoO25Nc+ROg6EJ2LfBVzdrgog=
|
||||
modernc.org/sqlite v1.54.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
||||
+33
-17
@@ -10,6 +10,7 @@ import (
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
_ "net/http/pprof"
|
||||
@@ -90,6 +91,7 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
api.HandleFunc("GET /users", withUser(userGetHandler))
|
||||
api.HandleFunc("POST /users", withSelfOrAdmin(usersPostHandler))
|
||||
api.HandleFunc("PUT /users", withUser(userPutHandler))
|
||||
api.HandleFunc("PATCH /users/pinnedItems", withUser(userPatchPinnedItemsHandler))
|
||||
api.HandleFunc("DELETE /users", withSelfOrAdmin(userDeleteHandler))
|
||||
publicApi.HandleFunc("GET /users", withUser(userGetHandler))
|
||||
|
||||
@@ -127,7 +129,7 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
api.HandleFunc("POST /resources/archive", withUser(archiveCreateHandler))
|
||||
api.HandleFunc("POST /resources/unarchive", withUser(unarchiveHandler))
|
||||
api.HandleFunc("GET /resources/download", withUser(downloadHandler))
|
||||
api.HandleFunc("GET /resources/preview", withTimeout(60*time.Second, withUserHelper(previewHandler)))
|
||||
api.HandleFunc("GET /resources/preview", withTimeout(30*time.Second, withUserHelper(previewHandler)))
|
||||
api.HandleFunc("POST /resources/pause", withUser(resourcePauseHandler))
|
||||
publicApi.HandleFunc("GET /resources", withHashFile(publicGetResourceHandler))
|
||||
publicApi.HandleFunc("GET /resources/items", withHashFile(publicItemsGetHandler))
|
||||
@@ -137,7 +139,7 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
publicApi.HandleFunc("DELETE /resources/bulk", withHashFile(publicBulkDeleteHandler))
|
||||
publicApi.HandleFunc("PATCH /resources", withHashFile(publicPatchHandler))
|
||||
publicApi.HandleFunc("GET /resources/download", withHashFile(publicDownloadHandler))
|
||||
publicApi.HandleFunc("GET /resources/preview", withHashFile(publicPreviewHandler))
|
||||
publicApi.HandleFunc("GET /resources/preview", withTimeout(30*time.Second, withHashFileHelper(publicPreviewHandler)))
|
||||
publicApi.HandleFunc("POST /resources/pause", withHashFile(publicPauseHandler))
|
||||
// Legacy routes (backwards compatibility)
|
||||
api.HandleFunc("GET /raw", withUser(downloadHandler))
|
||||
@@ -164,6 +166,7 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
api.HandleFunc("PATCH /share", withPermShare(sharePatchHandler))
|
||||
api.HandleFunc("DELETE /share", withPermShare(shareDeleteHandler))
|
||||
publicApi.HandleFunc("GET /share/info", withOrWithoutUser(shareInfoHandler))
|
||||
publicApi.HandleFunc("PATCH /share/pinnedItems", withPermShare(sharePatchPinnedItemsHandler))
|
||||
publicApi.HandleFunc("GET /share/image", withHashFile(getShareImage))
|
||||
|
||||
// ========================================
|
||||
@@ -253,16 +256,28 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
})
|
||||
}
|
||||
|
||||
var scheme string
|
||||
port := ""
|
||||
srv := &http.Server{
|
||||
Addr: fmt.Sprintf("%v:%v", config.Server.ListenAddress, config.Server.Port),
|
||||
Handler: muxWithMiddleware(router),
|
||||
}
|
||||
listenAddress := config.Server.ListenAddress
|
||||
go func() {
|
||||
// Determine whether to use HTTPS (TLS) or HTTP
|
||||
if config.Server.TLSCert != "" && config.Server.TLSKey != "" {
|
||||
var listener net.Listener
|
||||
|
||||
if config.Server.Socket != "" {
|
||||
if err := os.Remove(config.Server.Socket); err != nil && !os.IsNotExist(err) {
|
||||
logger.Fatalf("Could not remove existing socket: %v", err)
|
||||
}
|
||||
var err error
|
||||
listener, err = net.Listen("unix", config.Server.Socket)
|
||||
if err != nil {
|
||||
logger.Fatalf("Could not listen on unix socket: %v", err)
|
||||
}
|
||||
logger.Infof("Running at : unix://%s%s", config.Server.Socket, config.Server.BaseURL)
|
||||
} else if config.Server.TLSCert != "" && config.Server.TLSKey != "" {
|
||||
var scheme string
|
||||
port := ""
|
||||
// Determine whether to use HTTPS (TLS) or HTTP
|
||||
// Load the TLS certificate and key
|
||||
cer, err := tls.LoadX509KeyPair(config.Server.TLSCert, config.Server.TLSKey)
|
||||
if err != nil {
|
||||
@@ -286,8 +301,6 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
logger.Infof("Running at : %s", fullURL)
|
||||
|
||||
// Attempt to get listener from socket activation with TLS configuration
|
||||
var listener net.Listener
|
||||
|
||||
socketActivationListeners, err := activation.TLSListeners(tlsConfig)
|
||||
if err == nil && len(socketActivationListeners) > 0 {
|
||||
listener = socketActivationListeners[0]
|
||||
@@ -306,10 +319,9 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
}
|
||||
}
|
||||
|
||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
logger.Fatalf("Server error: %v", err)
|
||||
}
|
||||
} else {
|
||||
var scheme string
|
||||
port := ""
|
||||
// Set HTTP scheme and the default port for HTTP
|
||||
scheme = "http"
|
||||
if config.Server.Port != 80 {
|
||||
@@ -320,8 +332,6 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
fullURL := fmt.Sprintf("%s://%s%s%s", scheme, listenAddress, port, config.Server.BaseURL)
|
||||
logger.Infof("Running at : %s", fullURL)
|
||||
|
||||
var listener net.Listener
|
||||
|
||||
// Attempt to get the listener from socket activation
|
||||
socketActivationListeners, err := activation.Listeners()
|
||||
if err == nil && len(socketActivationListeners) > 0 {
|
||||
@@ -347,10 +357,10 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
}
|
||||
}
|
||||
|
||||
// Start HTTP server
|
||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
logger.Fatalf("Server error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
logger.Fatalf("Server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -389,6 +399,12 @@ func StartHttp(ctx context.Context, storage *bolt.BoltStore, shutdownComplete ch
|
||||
logger.Info("HTTP server shut down gracefully.")
|
||||
}
|
||||
|
||||
if config.Server.Socket != "" {
|
||||
if err := os.Remove(config.Server.Socket); err != nil && !os.IsNotExist(err) {
|
||||
logger.Debugf("Could not remove unix socket: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Signal that shutdown is complete
|
||||
close(shutdownComplete)
|
||||
}
|
||||
+72
-54
@@ -5,14 +5,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/adapters/fs/files"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/ffmpeg"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing"
|
||||
)
|
||||
|
||||
// subtitlesHandler handles subtitle requests for both external files and embedded streams
|
||||
@@ -37,58 +36,49 @@ func subtitlesHandler(w http.ResponseWriter, r *http.Request, d *requestContext)
|
||||
name := r.URL.Query().Get("name")
|
||||
embedded := r.URL.Query().Get("embedded") == "true"
|
||||
|
||||
if path == "" || source == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("path and source are required")
|
||||
}
|
||||
if name == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("name parameter is required")
|
||||
}
|
||||
|
||||
userscope, err := d.user.GetScopeForSourceName(source)
|
||||
fileInfo, err := files.FileInfoFaster(utils.FileOptions{
|
||||
FollowSymlinks: true,
|
||||
Path: path,
|
||||
Source: source,
|
||||
Expand: true,
|
||||
Content: false,
|
||||
Metadata: true,
|
||||
ExtractEmbeddedSubtitles: config.Integrations.Media.ExtractEmbeddedSubtitles,
|
||||
ShowHidden: d.user.ShowHidden,
|
||||
HideFileExt: d.user.HideFileExt,
|
||||
SkipExtendedAttrs: false,
|
||||
}, store.Access, d.user, store.Share)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, err
|
||||
return errToStatus(err), err
|
||||
}
|
||||
if !strings.HasPrefix(fileInfo.Type, "video") {
|
||||
return http.StatusNotFound, fmt.Errorf("file is not a video")
|
||||
}
|
||||
|
||||
idx := indexing.GetIndex(source)
|
||||
if idx == nil {
|
||||
return http.StatusNotFound, fmt.Errorf("source %s not found", source)
|
||||
track := findSubtitleTrack(fileInfo.Subtitles, name, embedded)
|
||||
if track == nil {
|
||||
return http.StatusNotFound, fmt.Errorf("subtitle track '%s' not found", name)
|
||||
}
|
||||
|
||||
realPath, _, err := idx.GetRealPath(userscope, path)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, fmt.Errorf("file not found: %v", err)
|
||||
}
|
||||
|
||||
parentDir := filepath.Dir(realPath)
|
||||
var content string
|
||||
|
||||
if !embedded {
|
||||
content, err = utils.GetSubtitleSidecarContent(filepath.Join(parentDir, name))
|
||||
subtitlePath := filepath.Join(filepath.Dir(fileInfo.RealPath), filepath.Base(track.Name))
|
||||
content, err = utils.GetSubtitleSidecarContent(subtitlePath)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("failed to get subtitle sidecar content: %v", err)
|
||||
}
|
||||
} else {
|
||||
// For embedded subtitles, we need to find the stream index by name
|
||||
// Get file modification time for caching
|
||||
fileInfo, err := os.Stat(realPath)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("failed to stat file: %v", err)
|
||||
}
|
||||
|
||||
// Detect embedded subtitles
|
||||
embeddedSubs := ffmpeg.DetectEmbeddedSubtitles(realPath, fileInfo.ModTime())
|
||||
|
||||
// Find the subtitle track by name
|
||||
var streamIndex *int
|
||||
for _, sub := range embeddedSubs {
|
||||
if sub.Name == name {
|
||||
streamIndex = sub.Index
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if streamIndex == nil {
|
||||
if track.Index == nil {
|
||||
return http.StatusNotFound, fmt.Errorf("embedded subtitle track '%s' not found", name)
|
||||
}
|
||||
|
||||
content, err = ffmpeg.ExtractSubtitleContent(realPath, *streamIndex)
|
||||
content, err = ffmpeg.ExtractSubtitleContent(fileInfo.RealPath, *track.Index)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("failed to extract embedded subtitle: %v", err)
|
||||
}
|
||||
@@ -102,6 +92,16 @@ func subtitlesHandler(w http.ResponseWriter, r *http.Request, d *requestContext)
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
func findSubtitleTrack(subtitles []utils.SubtitleTrack, name string, embedded bool) *utils.SubtitleTrack {
|
||||
for i := range subtitles {
|
||||
sub := &subtitles[i]
|
||||
if sub.Name == name && sub.Embedded == embedded {
|
||||
return sub
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// metadataHandler returns the same directory resource shape as GET /api/resources with metadata enabled,
|
||||
// for client-side patching after a fast listing load.
|
||||
// @Summary Directory with media metadata
|
||||
@@ -196,19 +196,26 @@ func lyricsHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (i
|
||||
if path == "" || source == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("path and source are required")
|
||||
}
|
||||
userscope, err := d.user.GetScopeForSourceName(source)
|
||||
|
||||
fileInfo, err := files.FileInfoFaster(utils.FileOptions{
|
||||
FollowSymlinks: true,
|
||||
Path: path,
|
||||
Source: source,
|
||||
Expand: true,
|
||||
Content: false,
|
||||
Metadata: false,
|
||||
ShowHidden: d.user.ShowHidden,
|
||||
HideFileExt: d.user.HideFileExt,
|
||||
SkipExtendedAttrs: false,
|
||||
}, store.Access, d.user, store.Share)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, err
|
||||
return errToStatus(err), err
|
||||
}
|
||||
idx := indexing.GetIndex(source)
|
||||
if idx == nil {
|
||||
return http.StatusNotFound, fmt.Errorf("source %s not found", source)
|
||||
if !strings.HasPrefix(fileInfo.Type, "audio") {
|
||||
return http.StatusNotFound, fmt.Errorf("file is not an audio file")
|
||||
}
|
||||
realPath, _, err := idx.GetRealPath(userscope, path)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
lyrics, err := files.ExtractLyrics(realPath)
|
||||
|
||||
lyrics, err := files.ExtractLyrics(fileInfo.RealPath)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("failed to extract lyrics: %v", err)
|
||||
}
|
||||
@@ -230,15 +237,26 @@ func publicLyricsHandler(w http.ResponseWriter, r *http.Request, d *requestConte
|
||||
if !ok {
|
||||
return http.StatusNotFound, fmt.Errorf("source not found")
|
||||
}
|
||||
idx := indexing.GetIndex(sourceCfg.Name)
|
||||
if idx == nil {
|
||||
return http.StatusNotFound, fmt.Errorf("source not found")
|
||||
}
|
||||
realPath, _, err := idx.GetRealPath(d.IndexPath)
|
||||
|
||||
fileInfo, err := files.FileInfoFaster(utils.FileOptions{
|
||||
Path: d.IndexPath,
|
||||
Source: sourceCfg.Name,
|
||||
Expand: true,
|
||||
Content: false,
|
||||
Metadata: false,
|
||||
ShowHidden: d.share.ShowHidden,
|
||||
HideFileExt: d.user.HideFileExt,
|
||||
FollowSymlinks: false,
|
||||
SkipExtendedAttrs: false,
|
||||
}, store.Access, d.shareUser, store.Share)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, errors.New("could not find real path for file")
|
||||
return errToStatus(err), err
|
||||
}
|
||||
lyrics, err := files.ExtractLyrics(realPath)
|
||||
if !strings.HasPrefix(fileInfo.Type, "audio") {
|
||||
return http.StatusNotFound, fmt.Errorf("file is not an audio file")
|
||||
}
|
||||
|
||||
lyrics, err := files.ExtractLyrics(fileInfo.RealPath)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, errors.New("failed to extract lyrics")
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ func withHashFileHelper(fn handleFunc) handleFunc {
|
||||
ShowHidden: link.ShowHidden,
|
||||
HideFileExt: link.HideFileExt,
|
||||
FollowSymlinks: true,
|
||||
ShowPinnedItems: true,
|
||||
ShareHash: hash,
|
||||
}, store.Access, data.shareUser, store.Share)
|
||||
if err != nil {
|
||||
logger.Errorf("error fetching file info for share. hash=%v path=%v error=%v", hash, path, err)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/gtsteffaniak/filebrowser/backend/adapters/fs/files"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/settings"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing/iteminfo"
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
@@ -482,7 +482,7 @@ func processOnlyOfficeCallback(w http.ResponseWriter, r *http.Request, d *reques
|
||||
//
|
||||
// When the document is fully closed by all editors,
|
||||
// the document key should no longer be re-used.
|
||||
deleteOfficeId(source, path)
|
||||
deleteOfficeId(source, path, user)
|
||||
|
||||
// Send log event for document closure and clean up log context
|
||||
if logContext := getOnlyOfficeLogContext(data.Key); logContext != nil {
|
||||
@@ -755,14 +755,21 @@ func getOnlyOfficeId(realpath string) (string, error) {
|
||||
return "", fmt.Errorf("document key not found")
|
||||
}
|
||||
|
||||
func deleteOfficeId(source, path string) {
|
||||
idx := indexing.GetIndex(source)
|
||||
if idx == nil {
|
||||
logger.Errorf("deleteOfficeId: failed to find source index for user home dir creation: %s", source)
|
||||
return
|
||||
func deleteOfficeId(source, path string, user *users.User) {
|
||||
fi, err := files.FileInfoFaster(utils.FileOptions{
|
||||
Path: path,
|
||||
Source: source,
|
||||
Expand: false,
|
||||
FollowSymlinks: true,
|
||||
}, store.Access, user, store.Share)
|
||||
key := path
|
||||
if fi != nil && fi.RealPath != "" {
|
||||
key = fi.RealPath
|
||||
}
|
||||
realpath, _, _ := idx.GetRealPath(path)
|
||||
utils.OnlyOfficeCache.Delete(realpath)
|
||||
if err != nil {
|
||||
logger.Errorf("deleteOfficeId: failed to resolve realpath, source=%s, path=%s: %v", source, path, err)
|
||||
}
|
||||
utils.OnlyOfficeCache.Delete(key)
|
||||
}
|
||||
|
||||
// parseOnlyOfficeJWT parses the JWT token from OnlyOffice callback
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/adapters/fs/files"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/access"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/share"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/storage/bolt"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing/iteminfo"
|
||||
)
|
||||
|
||||
func TestResolveOnlyOfficeDownloadURL(t *testing.T) {
|
||||
@@ -83,6 +92,77 @@ func TestResolveOnlyOfficeDownloadURL(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestDeleteOfficeId(t *testing.T) {
|
||||
const rawPath = "/docs/document.docx"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
resolve func(utils.FileOptions) (*iteminfo.ExtendedFileInfo, error)
|
||||
deleteKey string
|
||||
remainKey string
|
||||
}{
|
||||
{
|
||||
name: "deletes resolved realpath",
|
||||
resolve: func(utils.FileOptions) (*iteminfo.ExtendedFileInfo, error) {
|
||||
return &iteminfo.ExtendedFileInfo{RealPath: "/some/path/document.docx"}, nil
|
||||
},
|
||||
deleteKey: "/some/path/document.docx",
|
||||
remainKey: rawPath,
|
||||
},
|
||||
{
|
||||
name: "fallback to raw path on error",
|
||||
resolve: func(utils.FileOptions) (*iteminfo.ExtendedFileInfo, error) {
|
||||
return nil, fmt.Errorf("could not resolve path")
|
||||
},
|
||||
deleteKey: rawPath,
|
||||
remainKey: "/some/path/document.docx",
|
||||
},
|
||||
{
|
||||
name: "also deletes realpath when partially resolved before erroring",
|
||||
resolve: func(utils.FileOptions) (*iteminfo.ExtendedFileInfo, error) {
|
||||
return &iteminfo.ExtendedFileInfo{RealPath: "/some/path/document.docx"}, fmt.Errorf("access check failed")
|
||||
},
|
||||
deleteKey: "/some/path/document.docx",
|
||||
remainKey: rawPath,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
origStore := store
|
||||
store = &bolt.BoltStore{Access: &access.Storage{}, Share: &share.Storage{}}
|
||||
t.Cleanup(func() { store = origStore })
|
||||
|
||||
origFunc := files.FileInfoFasterFunc
|
||||
t.Cleanup(func() { files.FileInfoFasterFunc = origFunc })
|
||||
files.FileInfoFasterFunc = func(opts utils.FileOptions, accessStore *access.Storage, user *users.User, shareStore *share.Storage) (*iteminfo.ExtendedFileInfo, error) {
|
||||
if opts.Path != rawPath {
|
||||
t.Errorf("expected opts.Path=%q, got %q", rawPath, opts.Path)
|
||||
}
|
||||
if opts.Source != "source" {
|
||||
t.Errorf("expected opts.Source=%q, got %q", "source", opts.Source)
|
||||
}
|
||||
if !opts.FollowSymlinks {
|
||||
t.Error("expected FollowSymlinks=true")
|
||||
}
|
||||
return tt.resolve(opts)
|
||||
}
|
||||
utils.OnlyOfficeCache.Set(tt.deleteKey, "document-key")
|
||||
utils.OnlyOfficeCache.Set(tt.remainKey, "other-key")
|
||||
t.Cleanup(func() {
|
||||
utils.OnlyOfficeCache.Delete(tt.deleteKey)
|
||||
utils.OnlyOfficeCache.Delete(tt.remainKey)
|
||||
})
|
||||
deleteOfficeId("source", rawPath, &users.User{})
|
||||
if _, err := getOnlyOfficeId(tt.deleteKey); err == nil {
|
||||
t.Errorf("expected cache entry %q to be deleted", tt.deleteKey)
|
||||
}
|
||||
if _, err := getOnlyOfficeId(tt.remainKey); err != nil {
|
||||
t.Errorf("expected cache entry %q to remain, but it was deleted", tt.remainKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOnlyOfficeURLHostsMatch(t *testing.T) {
|
||||
mustParse := func(raw string) *url.URL {
|
||||
t.Helper()
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing"
|
||||
)
|
||||
|
||||
// pinnedItemPatchRequest is the JSON body for PATCH /api/users/pinnedItems.
|
||||
type pinnedItemPatchRequest struct {
|
||||
Source string `json:"source" validate:"required"`
|
||||
Path string `json:"path" validate:"required"` // scope-relative parent directory
|
||||
Name string `json:"name" validate:"required"` // item basename within path
|
||||
}
|
||||
|
||||
// sharePinnedItemPatchRequest is the JSON body for PATCH /public/api/share/pinnedItems.
|
||||
type sharePinnedItemPatchRequest struct {
|
||||
Path string `json:"path" validate:"required"` // share-relative parent directory
|
||||
Name string `json:"name" validate:"required"` // item basename within path
|
||||
}
|
||||
|
||||
// scopeRelativeDirToIndexPath maps a scope-relative directory to source and index paths.
|
||||
func scopeRelativeDirToIndexPath(sourceName, userScope, directoryPath string) (sourcePath, indexDirPath string, err error) {
|
||||
userScope = strings.TrimRight(userScope, "/")
|
||||
source, ok := users.ResolveSourceKey(sourceName)
|
||||
if !ok {
|
||||
return "", "", fmt.Errorf("source not found: %s", sourceName)
|
||||
}
|
||||
idx := indexing.GetIndex(source.Name)
|
||||
if idx == nil {
|
||||
return "", "", fmt.Errorf("index not found for source %s", source.Name)
|
||||
}
|
||||
|
||||
cleanDir, err := utils.SanitizeUserPath(directoryPath)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("invalid path: %w", err)
|
||||
}
|
||||
|
||||
fullDirPath := utils.JoinPathAsUnix(userScope, cleanDir)
|
||||
return source.Path, idx.MakeIndexPath(fullDirPath, true), nil
|
||||
}
|
||||
|
||||
// normalizeShareRelativeDir returns a normalized share-relative directory path key.
|
||||
func normalizeShareRelativeDir(shareRelDir string) (string, error) {
|
||||
if shareRelDir == "" || shareRelDir == "/" {
|
||||
return "/", nil
|
||||
}
|
||||
cleanDir, err := utils.SanitizeUserPath(shareRelDir)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid path: %w", err)
|
||||
}
|
||||
return utils.AddTrailingSlashIfNotExists(cleanDir), nil
|
||||
}
|
||||
|
||||
// pinnedItemAction returns the patch action query param, defaulting to "add".
|
||||
func pinnedItemAction(r *http.Request) string {
|
||||
action := strings.ToLower(strings.TrimSpace(r.URL.Query().Get("action")))
|
||||
if action == "" {
|
||||
return "add"
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
// userPatchPinnedItemsHandler adds or removes a single pinned item for the authenticated user.
|
||||
// @Summary Add or remove a pinned item
|
||||
// @Description Patches one pinned item at a time. Defaults to add; pass ?action=remove to unpin.
|
||||
// @Tags Users
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param action query string false "add (default) or remove"
|
||||
// @Param body body pinnedItemPatchRequest true "Pinned item"
|
||||
// @Success 204 "No Content"
|
||||
// @Failure 400 {object} map[string]string "Bad Request"
|
||||
// @Failure 403 {object} map[string]string "Forbidden"
|
||||
// @Failure 500 {object} map[string]string "Internal Server Error"
|
||||
// @Router /api/users/pinnedItems [patch]
|
||||
func userPatchPinnedItemsHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
|
||||
var body pinnedItemPatchRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("failed to decode body: %w", err)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
action := pinnedItemAction(r)
|
||||
if action != "add" && action != "remove" {
|
||||
return http.StatusBadRequest, fmt.Errorf("action must be add or remove")
|
||||
}
|
||||
|
||||
if body.Source == "" || body.Path == "" || body.Name == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("source, path, and name are required")
|
||||
}
|
||||
cleanPath, err := utils.SanitizeUserPath(body.Path)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, err
|
||||
}
|
||||
body.Path = cleanPath
|
||||
|
||||
cleanName, err := utils.SanitizeUserPath(body.Name)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, err
|
||||
}
|
||||
body.Name = cleanName
|
||||
|
||||
source, ok := users.ResolveSourceKey(body.Source)
|
||||
if !ok {
|
||||
return http.StatusBadRequest, fmt.Errorf("source not found: %s", body.Source)
|
||||
}
|
||||
if !d.user.HasSourceByPath(source.Path) {
|
||||
return http.StatusForbidden, fmt.Errorf("access denied to source %s", body.Source)
|
||||
}
|
||||
|
||||
userScope, err := d.user.GetScopeForSourcePath(source.Path)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, err
|
||||
}
|
||||
|
||||
sourcePath, indexDirPath, err := scopeRelativeDirToIndexPath(body.Source, userScope, body.Path)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, err
|
||||
}
|
||||
|
||||
u, err := store.Users.Get(d.user.ID)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
pinned := u.EnsurePinnedItems()
|
||||
switch action {
|
||||
case "add":
|
||||
pinned.Add(sourcePath, indexDirPath, body.Name)
|
||||
case "remove":
|
||||
pinned.Remove(sourcePath, indexDirPath, body.Name)
|
||||
}
|
||||
|
||||
if err := store.Users.Update(u, d.user.Permissions.Admin, "PinnedItems"); err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
return http.StatusNoContent, nil
|
||||
}
|
||||
+32
-11
@@ -84,6 +84,22 @@ func previewHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func shouldServeOriginalPreview(ext string, resizable bool, realPath, previewSize string, fileSize int64) bool {
|
||||
if !resizable {
|
||||
return false
|
||||
}
|
||||
// HEIC/TIFF still need conversion for reliable web display.
|
||||
switch ext {
|
||||
case ".heic", ".heif", ".tiff", ".tif":
|
||||
return false
|
||||
}
|
||||
const maxSizeForOriginal = 256 * 1024 // 256KB
|
||||
if config.Server.DisableResize || fileSize < maxSizeForOriginal {
|
||||
return true
|
||||
}
|
||||
return preview.ShouldServeOriginalImage(realPath, previewSize)
|
||||
}
|
||||
|
||||
func rawFileHandler(w http.ResponseWriter, r *http.Request, file iteminfo.ExtendedFileInfo) (int, error) {
|
||||
fd, err := os.Open(file.RealPath)
|
||||
if err != nil {
|
||||
@@ -155,6 +171,11 @@ func getDirectoryPreview(r *http.Request, d *requestContext, frameIndex int) (*i
|
||||
}
|
||||
|
||||
func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
|
||||
ctx := r.Context()
|
||||
if d.ctx != nil {
|
||||
ctx = d.ctx
|
||||
}
|
||||
|
||||
previewSize := r.URL.Query().Get("size")
|
||||
if !(previewSize == "large" || previewSize == "original" || previewSize == "xlarge") {
|
||||
previewSize = "small"
|
||||
@@ -191,6 +212,12 @@ func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext
|
||||
}
|
||||
fileInfo, err := getDirectoryPreview(r, d, dirFrameIndex)
|
||||
if err != nil {
|
||||
if isClientCancellation(ctx, err) {
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
if ctx.Err() == context.DeadlineExceeded || errors.Is(err, context.DeadlineExceeded) {
|
||||
return http.StatusRequestTimeout, fmt.Errorf("preview generation timed out")
|
||||
}
|
||||
logger.Errorf("error getting directory preview: %v", err)
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -203,9 +230,9 @@ func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext
|
||||
ext := strings.ToLower(filepath.Ext(d.fileInfo.Name))
|
||||
resizable := iteminfo.ResizableImageTypes[ext]
|
||||
|
||||
// For small, displayable images (jpg, png, etc.) serve the original to avoid processing.
|
||||
const maxSizeForOriginal = 128 * 1024 // 128KB
|
||||
if resizable && (config.Server.DisableResize || d.fileInfo.Size < maxSizeForOriginal) && isImage {
|
||||
// For small displayable images (jpg, png, etc.) serve the original to avoid processing.
|
||||
// Also serve the original when dimensions already fit the requested preview size.
|
||||
if isImage && shouldServeOriginalPreview(ext, resizable, d.fileInfo.RealPath, previewSize, d.fileInfo.Size) {
|
||||
return rawFileHandler(w, r, d.fileInfo)
|
||||
}
|
||||
|
||||
@@ -223,12 +250,6 @@ func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext
|
||||
officeUrl = scheme + "://" + r.Host + pathUrl
|
||||
}
|
||||
}
|
||||
// Use the context from the request context (which includes timeout)
|
||||
ctx := r.Context()
|
||||
if d.ctx != nil {
|
||||
ctx = d.ctx
|
||||
}
|
||||
|
||||
previewImg, err := preview.GetPreviewForFile(ctx, d.fileInfo, previewSize, officeUrl, seekPercentage)
|
||||
if err != nil {
|
||||
// Check if it was a context cancellation (client navigated away)
|
||||
@@ -239,8 +260,8 @@ func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext
|
||||
|
||||
// Check if it was a context timeout (server-side timeout)
|
||||
if ctx.Err() == context.DeadlineExceeded || errors.Is(err, context.DeadlineExceeded) {
|
||||
logger.Errorf("Preview timeout for file '%s' after 60 seconds", d.fileInfo.Name)
|
||||
return http.StatusRequestTimeout, fmt.Errorf("preview generation timed out after 60 seconds")
|
||||
logger.Errorf("Preview timeout for file '%s' after 15 seconds", d.fileInfo.Name)
|
||||
return http.StatusRequestTimeout, fmt.Errorf("preview generation timed out after 15 seconds")
|
||||
}
|
||||
|
||||
// Log detailed error information for actual server errors
|
||||
|
||||
@@ -103,6 +103,7 @@ func resourceGetHandler(w http.ResponseWriter, r *http.Request, d *requestContex
|
||||
HideFileExt: d.user.HideFileExt,
|
||||
SkipExtendedAttrs: skipExtendedAttrs,
|
||||
ShowSharedAttr: true,
|
||||
ShowPinnedItems: true,
|
||||
}, store.Access, d.user, store.Share)
|
||||
if err != nil {
|
||||
return errToStatus(err), err
|
||||
@@ -907,7 +908,7 @@ func resourcePatchHandler(w http.ResponseWriter, r *http.Request, d *requestCont
|
||||
}
|
||||
|
||||
if srcIdx.Config.ReadOnly && req.Action == "move" {
|
||||
item.Message = "source source is read-only"
|
||||
item.Message = "From source is read-only and cannot be moved"
|
||||
if d.share != nil {
|
||||
response.Failed = append(response.Failed, MoveCopyItem{
|
||||
Message: item.Message,
|
||||
|
||||
@@ -700,3 +700,78 @@ func redirectToShare(w http.ResponseWriter, r *http.Request, d *requestContext)
|
||||
http.Redirect(w, r, newURL, http.StatusMovedPermanently)
|
||||
return http.StatusMovedPermanently, nil
|
||||
}
|
||||
|
||||
// publicSharePatchPinnedItemsHandler adds or removes a pinned item on a share link.
|
||||
// @Summary Add or remove a pinned item on a share
|
||||
// @Description Patches one pinned item at a time for share owners. Defaults to add; pass ?action=remove to unpin.
|
||||
// @Tags Shares
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param hash query string true "Share hash"
|
||||
// @Param action query string false "add (default) or remove"
|
||||
// @Param body body sharePinnedItemPatchRequest true "Pinned item"
|
||||
// @Success 204 "No Content"
|
||||
// @Failure 400 {object} map[string]string "Bad Request"
|
||||
// @Failure 403 {object} map[string]string "Forbidden"
|
||||
// @Failure 404 {object} map[string]string "Share not found"
|
||||
// @Failure 500 {object} map[string]string "Internal Server Error"
|
||||
// @Router /public/api/share/pinnedItems [patch]
|
||||
func sharePatchPinnedItemsHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
|
||||
hash := r.URL.Query().Get("hash")
|
||||
if hash == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("hash is required")
|
||||
}
|
||||
|
||||
link, err := store.Share.GetByHash(hash)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, fmt.Errorf("share hash not found")
|
||||
}
|
||||
|
||||
if d.user.Username == "anonymous" || !link.UserCanEdit(d.user) {
|
||||
return http.StatusForbidden, fmt.Errorf("share pin editing is not allowed for this user")
|
||||
}
|
||||
|
||||
if link.ShareType == "upload" {
|
||||
return http.StatusForbidden, fmt.Errorf("pinning is disabled for upload shares")
|
||||
}
|
||||
|
||||
var body sharePinnedItemPatchRequest
|
||||
if err = json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("failed to decode body: %w", err)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
action := pinnedItemAction(r)
|
||||
if action != "add" && action != "remove" {
|
||||
return http.StatusBadRequest, fmt.Errorf("action must be add or remove")
|
||||
}
|
||||
|
||||
if body.Path == "" || body.Name == "" {
|
||||
return http.StatusBadRequest, fmt.Errorf("path and name are required")
|
||||
}
|
||||
|
||||
shareRelDir, err := normalizeShareRelativeDir(body.Path)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("invalid path: %s", body.Path)
|
||||
}
|
||||
|
||||
cleanName, err := utils.SanitizeUserPath(body.Name)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("invalid name: %s", body.Name)
|
||||
}
|
||||
body.Name = cleanName
|
||||
|
||||
pinned := link.EnsurePinnedItems()
|
||||
switch action {
|
||||
case "add":
|
||||
pinned.Add(shareRelDir, body.Name)
|
||||
case "remove":
|
||||
pinned.Remove(shareRelDir, body.Name)
|
||||
}
|
||||
|
||||
if err := store.Share.Save(link); err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("failed to save share: %w", err)
|
||||
}
|
||||
|
||||
return http.StatusNoContent, nil
|
||||
}
|
||||
+38
-4
@@ -6,6 +6,7 @@ import (
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -96,6 +97,17 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *requestCont
|
||||
shareHash := ""
|
||||
data := make(map[string]interface{})
|
||||
disableNavButtons := config.Frontend.DisableNavButtons
|
||||
if d.share != nil {
|
||||
shareHash = d.share.Hash
|
||||
}
|
||||
if shareHash == "" {
|
||||
shareHash = icons.ShareHashFromHTTPPath(r.URL.Path, config.Server.BaseURL)
|
||||
}
|
||||
if shareHash != "" && d.share == nil && store != nil {
|
||||
if link, err := store.Share.GetByHash(shareHash); err == nil {
|
||||
d.share = link
|
||||
}
|
||||
}
|
||||
if d.share != nil {
|
||||
if d.share.Favicon != "" {
|
||||
if strings.HasPrefix(d.share.Favicon, "http") {
|
||||
@@ -124,7 +136,6 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *requestCont
|
||||
if shareFavicon != "" {
|
||||
favicon = shareFavicon
|
||||
}
|
||||
shareHash = d.share.Hash
|
||||
}
|
||||
// Set login icon URL
|
||||
loginIcon := staticURL + "/loginIcon"
|
||||
@@ -162,6 +173,20 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *requestCont
|
||||
pwaIcon256 := staticURL + "/icons/pwa-icon-256.png"
|
||||
pwaIcon512 := staticURL + "/icons/pwa-icon-512.png"
|
||||
|
||||
manifestURL := staticURL + "/site.webmanifest"
|
||||
if shareHash != "" {
|
||||
pwaStartURL := config.Server.BaseURL + "public/share/" + shareHash + "/"
|
||||
query := url.Values{}
|
||||
query.Set("start", pwaStartURL)
|
||||
if title != config.Frontend.Name {
|
||||
query.Set("name", title)
|
||||
}
|
||||
if description != config.Frontend.Description {
|
||||
query.Set("description", description)
|
||||
}
|
||||
manifestURL = staticURL + "/site.webmanifest?" + query.Encode()
|
||||
}
|
||||
|
||||
data["htmlVars"] = map[string]interface{}{
|
||||
"title": title,
|
||||
"customCSS": template.CSS(config.Frontend.Styling.CustomCSSRaw),
|
||||
@@ -183,7 +208,7 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *requestCont
|
||||
"pwaIcon192": pwaIcon192,
|
||||
"pwaIcon256": pwaIcon256,
|
||||
"pwaIcon512": pwaIcon512,
|
||||
"manifestURL": staticURL + "/site.webmanifest",
|
||||
"manifestURL": manifestURL,
|
||||
}
|
||||
|
||||
data["globalVars"] = map[string]interface{}{
|
||||
@@ -267,12 +292,21 @@ func setContentType(w http.ResponseWriter, path string) {
|
||||
}
|
||||
}
|
||||
|
||||
// manifestHandler serves the cached PWA manifest
|
||||
// manifestHandler serves the cached PWA manifest, optionally scoped to a public share.
|
||||
func manifestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/manifest+json")
|
||||
w.Header().Set("Cache-Control", "public, max-age=3600") // Cache for 1 hour
|
||||
|
||||
if err := json.NewEncoder(w).Encode(icons.CachedManifest); err != nil {
|
||||
manifest := icons.CachedManifest
|
||||
if startURL := r.URL.Query().Get("start"); startURL != "" {
|
||||
name := r.URL.Query().Get("name")
|
||||
description := r.URL.Query().Get("description")
|
||||
if shareManifest, ok := icons.ManifestForShare(config.Server.BaseURL, startURL, name, description); ok {
|
||||
manifest = shareManifest
|
||||
}
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(manifest); err != nil {
|
||||
http.Error(w, "Failed to serve manifest", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/auth"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/errors"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/users"
|
||||
"github.com/pquerna/otp/totp"
|
||||
)
|
||||
|
||||
func otpRequest(username, password, code string) *http.Request {
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/auth/otp?username="+username, http.NoBody)
|
||||
req.Header.Set("X-Password", password)
|
||||
if code != "" {
|
||||
req.Header.Set("X-Secret", code)
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func TestVerifyOTP_CachedSecretTakesPrecedence(t *testing.T) {
|
||||
setupTestEnv(t)
|
||||
|
||||
oldSecret := "SOMEOLDSECRET234"
|
||||
user := &users.User{
|
||||
ID: 1,
|
||||
Username: "test",
|
||||
NonAdminEditable: users.NonAdminEditable{Password: "testPass"},
|
||||
TOTPSecret: oldSecret,
|
||||
OtpEnabled: true,
|
||||
}
|
||||
if err := store.Users.Save(user, true, true); err != nil {
|
||||
t.Fatalf("failed to save user: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { auth.TotpCache.Delete(user.Username) })
|
||||
|
||||
d := &requestContext{user: user}
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
if _, err := generateOTPHandler(rec, otpRequest(user.Username, "testPass", ""), d); err != nil {
|
||||
t.Fatalf("genration failed: %v", err)
|
||||
}
|
||||
var resp map[string]string
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatalf("failed to decode response: %v", err)
|
||||
}
|
||||
u, err := url.Parse(resp["url"])
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse url: %v", err)
|
||||
}
|
||||
newSecret := u.Query().Get("secret")
|
||||
if newSecret == oldSecret {
|
||||
t.Fatal("expected a fresh secret")
|
||||
}
|
||||
oldCode, err := totp.GenerateCode(oldSecret, time.Now())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to generate old code: %v", err)
|
||||
}
|
||||
if _, verifyErr := verifyOTPHandler(httptest.NewRecorder(), otpRequest(user.Username, "testPass", oldCode), d); verifyErr == nil {
|
||||
t.Error("expected old secret to be rejected")
|
||||
}
|
||||
newCode, err := totp.GenerateCode(newSecret, time.Now())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to generate new code: %v", err)
|
||||
}
|
||||
if _, verifyErr := verifyOTPHandler(httptest.NewRecorder(), otpRequest(user.Username, "testPass", newCode), d); verifyErr != nil {
|
||||
t.Fatalf("expected new secret to be accepted: %v", verifyErr)
|
||||
}
|
||||
updated, err := store.Users.Get(user.Username)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to reload user: %v", err)
|
||||
}
|
||||
if updated.TOTPSecret != newSecret {
|
||||
t.Error("expected TOTPSecret to be updated to the new secret")
|
||||
}
|
||||
if _, found := auth.TotpCache.Get(user.Username); found {
|
||||
t.Error("expected cache to be cleared after verification")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogin_EnforcedOtp(t *testing.T) {
|
||||
setupTestEnv(t)
|
||||
config.Auth.Key = "test-key"
|
||||
config.Auth.TokenExpirationHours = 1
|
||||
config.Auth.Methods.PasswordAuth.EnforcedOtp = true
|
||||
|
||||
user := &users.User{ID: 2, Username: "loginuser", LoginMethod: users.LoginMethodPassword}
|
||||
d := &requestContext{user: user}
|
||||
|
||||
status, err := loginHandler(httptest.NewRecorder(), otpRequest(user.Username, "", ""), d)
|
||||
if status != http.StatusForbidden || err != errors.ErrNoTotpConfigured {
|
||||
t.Fatalf("expected login without TOTP to fail, got=%d err=%v", status, err)
|
||||
}
|
||||
|
||||
user.TOTPSecret = "SOMESECRET123456"
|
||||
if _, loginErr := loginHandler(httptest.NewRecorder(), otpRequest(user.Username, "", ""), d); loginErr != nil {
|
||||
t.Fatalf("expected login with TOTP to succed, got err=%v", loginErr)
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,7 @@ func prepForFrontend(u *users.User) {
|
||||
u.TOTPNonce = ""
|
||||
u.Scopes = u.GetFrontendScopes()
|
||||
u.SidebarLinks = GetFrontendSidebarLinks(u.SidebarLinks, u.ShowToolsInSidebar)
|
||||
u.PinnedItems = nil
|
||||
u.Locale = normalizeLocale(u.Locale)
|
||||
for i := range u.PasskeyCredentials {
|
||||
u.PasskeyCredentials[i].PublicKey = ""
|
||||
|
||||
@@ -2,6 +2,7 @@ package icons
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
@@ -205,6 +206,7 @@ func generateSingleIcon(previewService *preview.Service, sourceData []byte, icon
|
||||
|
||||
// Resize image using the preview service's Resize method
|
||||
err = previewService.Resize(
|
||||
context.Background(),
|
||||
bytes.NewReader(sourceData),
|
||||
outFile,
|
||||
preview.ResizeOptions{
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
type PWAManifest struct {
|
||||
Name string `json:"name"`
|
||||
ShortName string `json:"short_name"`
|
||||
ID string `json:"id"`
|
||||
Scope string `json:"scope"`
|
||||
Icons []PWAIcon `json:"icons"`
|
||||
StartURL string `json:"start_url"`
|
||||
Display string `json:"display"`
|
||||
@@ -40,6 +42,8 @@ func generatePWAManifest(name, description, baseURL, themeColor, pwaIcon192, pwa
|
||||
return PWAManifest{
|
||||
Name: name,
|
||||
ShortName: shortName,
|
||||
ID: baseURL,
|
||||
Scope: baseURL,
|
||||
StartURL: baseURL,
|
||||
Display: "standalone",
|
||||
BackgroundColor: "#ffffff",
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package icons
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
)
|
||||
|
||||
const maxManifestTextLen = 256
|
||||
|
||||
func isValidShareHash(hash string) bool {
|
||||
if len(hash) < 8 || len(hash) > 64 {
|
||||
return false
|
||||
}
|
||||
if strings.Contains(hash, "..") || strings.Contains(hash, "/") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ShareRootFromStartURL validates a share PWA start URL and returns the share root
|
||||
// used for manifest scope/id plus the normalized start URL.
|
||||
func ShareRootFromStartURL(baseURL, startURL string) (shareRoot, normalizedStart string, ok bool) {
|
||||
if startURL == "" || !strings.HasPrefix(startURL, baseURL) {
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
rel := strings.TrimPrefix(startURL, baseURL)
|
||||
if !strings.HasPrefix(rel, "public/share/") {
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
rest := strings.TrimPrefix(rel, "public/share/")
|
||||
hash, subPath, _ := strings.Cut(rest, "/")
|
||||
if !isValidShareHash(hash) {
|
||||
return "", "", false
|
||||
}
|
||||
if subPath != "" {
|
||||
if _, err := utils.SanitizeUserPath(subPath); err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
}
|
||||
|
||||
shareRoot = baseURL + "public/share/" + hash + "/"
|
||||
normalizedStart = startURL
|
||||
if !strings.HasPrefix(normalizedStart, shareRoot) && normalizedStart != strings.TrimSuffix(shareRoot, "/") {
|
||||
return "", "", false
|
||||
}
|
||||
if normalizedStart == baseURL+"public/share/"+hash {
|
||||
normalizedStart = shareRoot
|
||||
}
|
||||
|
||||
return shareRoot, normalizedStart, true
|
||||
}
|
||||
|
||||
// ShareHashFromHTTPPath extracts a share hash from common FileBrowser share routes.
|
||||
func ShareHashFromHTTPPath(path, baseURL string) string {
|
||||
prefixes := []string{
|
||||
strings.TrimSuffix(baseURL, "/") + "/public/share/",
|
||||
"/public/share/",
|
||||
"/share/",
|
||||
}
|
||||
for _, prefix := range prefixes {
|
||||
if !strings.HasPrefix(path, prefix) {
|
||||
continue
|
||||
}
|
||||
rest := strings.TrimPrefix(path, prefix)
|
||||
hash, _, _ := strings.Cut(rest, "/")
|
||||
if isValidShareHash(hash) {
|
||||
return hash
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func sanitizeManifestText(value string) string {
|
||||
if len(value) > maxManifestTextLen {
|
||||
return value[:maxManifestTextLen]
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// ManifestForShare returns a manifest scoped to a single public share link.
|
||||
func ManifestForShare(baseURL, startURL, name, description string) (PWAManifest, bool) {
|
||||
shareRoot, normalizedStart, ok := ShareRootFromStartURL(baseURL, startURL)
|
||||
if !ok {
|
||||
return PWAManifest{}, false
|
||||
}
|
||||
|
||||
manifest := CachedManifest
|
||||
manifest.StartURL = normalizedStart
|
||||
manifest.Scope = shareRoot
|
||||
manifest.ID = shareRoot
|
||||
|
||||
if name = sanitizeManifestText(strings.TrimSpace(name)); name != "" {
|
||||
manifest.Name = name
|
||||
shortName := name
|
||||
if len(shortName) > 12 {
|
||||
shortName = shortName[:12]
|
||||
}
|
||||
manifest.ShortName = shortName
|
||||
}
|
||||
if description = sanitizeManifestText(strings.TrimSpace(description)); description != "" {
|
||||
manifest.Description = description
|
||||
}
|
||||
|
||||
return manifest, true
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package icons
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestShareRootFromStartURL(t *testing.T) {
|
||||
baseURL := "/testing/"
|
||||
startURL := "/testing/public/share/abc123XYZ-_/"
|
||||
shareRoot, normalizedStart, ok := ShareRootFromStartURL(baseURL, startURL)
|
||||
if !ok {
|
||||
t.Fatal("expected valid share start URL")
|
||||
}
|
||||
if shareRoot != "/testing/public/share/abc123XYZ-_/" {
|
||||
t.Fatalf("unexpected share root: %q", shareRoot)
|
||||
}
|
||||
if normalizedStart != startURL {
|
||||
t.Fatalf("unexpected normalized start: %q", normalizedStart)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareRootFromStartURLRejectsTraversal(t *testing.T) {
|
||||
baseURL := "/testing/"
|
||||
startURL := "/testing/public/share/abc123XYZ-_/../secret/"
|
||||
_, _, ok := ShareRootFromStartURL(baseURL, startURL)
|
||||
if ok {
|
||||
t.Fatal("expected traversal path to be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareHashFromHTTPPath(t *testing.T) {
|
||||
baseURL := "/testing/"
|
||||
paths := []string{
|
||||
"/testing/public/share/hash1234567890abcdef/",
|
||||
"/public/share/hash1234567890abcdef/files",
|
||||
"/share/hash1234567890abcdef/",
|
||||
}
|
||||
for _, path := range paths {
|
||||
hash := ShareHashFromHTTPPath(path, baseURL)
|
||||
if hash != "hash1234567890abcdef" {
|
||||
t.Fatalf("path %q: got hash %q", path, hash)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareHashFromHTTPPathRejectsEmbeddedPrefix(t *testing.T) {
|
||||
baseURL := "/testing/"
|
||||
path := "/evil/route/share/hash1234567890abcdef/"
|
||||
hash := ShareHashFromHTTPPath(path, baseURL)
|
||||
if hash != "" {
|
||||
t.Fatalf("expected empty hash for non-prefixed path, got %q", hash)
|
||||
}
|
||||
}
|
||||
|
||||
func TestManifestForShare(t *testing.T) {
|
||||
CachedManifest = PWAManifest{
|
||||
Name: "FileBrowser Quantum",
|
||||
ShortName: "FBQ",
|
||||
StartURL: "/testing/",
|
||||
Scope: "/testing/",
|
||||
ID: "/testing/",
|
||||
}
|
||||
|
||||
manifest, ok := ManifestForShare(
|
||||
"/testing/",
|
||||
"/testing/public/share/hash1234567890abcdef/",
|
||||
"My Share",
|
||||
"Shared files",
|
||||
)
|
||||
if !ok {
|
||||
t.Fatal("expected share manifest")
|
||||
}
|
||||
if manifest.StartURL != "/testing/public/share/hash1234567890abcdef/" {
|
||||
t.Fatalf("unexpected start_url: %q", manifest.StartURL)
|
||||
}
|
||||
if manifest.Scope != "/testing/public/share/hash1234567890abcdef/" {
|
||||
t.Fatalf("unexpected scope: %q", manifest.Scope)
|
||||
}
|
||||
if manifest.Name != "My Share" {
|
||||
t.Fatalf("unexpected name: %q", manifest.Name)
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ func (idx *Index) indexDirectory(indexPath string, opts Options, scanner *Scanne
|
||||
if err2 != nil {
|
||||
return 0, false, err2
|
||||
}
|
||||
idx.UpdateMetadata(dirFileInfo, scanner)
|
||||
idx.UpdateMetadata(dirFileInfo, scanner, !opts.Recursive)
|
||||
|
||||
// Always store the calculated directory size in the in-memory map
|
||||
// This ensures parent directories are updated after copy/move operations
|
||||
|
||||
@@ -95,12 +95,6 @@ func (s *Scanner) executeScan() {
|
||||
s.fullScanCounter = 0
|
||||
}
|
||||
})
|
||||
scanMode := "full"
|
||||
if quick {
|
||||
scanMode = "quick"
|
||||
}
|
||||
logger.Debugf("[%s] scanner [%s] starting %s scan (full/quick cadence step %d of 5)", s.idx.Name, s.scanPath, scanMode, pre+1)
|
||||
|
||||
s.runIndexing(quick)
|
||||
s.updateSchedule()
|
||||
}
|
||||
@@ -635,7 +629,7 @@ func (s *Scanner) checkFolderModtime(folderPath string) (bool, error) {
|
||||
}
|
||||
|
||||
// Update metadata (will be batched)
|
||||
s.idx.UpdateMetadata(dirInfo, s)
|
||||
s.idx.UpdateMetadata(dirInfo, s, true)
|
||||
|
||||
// Track this directory as having been updated (for file purge logic)
|
||||
s.idx.mu.Lock()
|
||||
@@ -650,11 +644,17 @@ func (s *Scanner) checkFolderModtime(folderPath string) (bool, error) {
|
||||
|
||||
// Modtime unchanged - update last_updated to prevent folder from being purged
|
||||
// Note: we DON'T add this folder to scanUpdatedPaths, so Phase 2 won't check its files
|
||||
// Use cached aggregate size: BulkInsertItems overwrites DB size;0 would corrupt LoadFolderSizes on restart.
|
||||
// BulkInsertItems overwrites all columns — preserve size/hasPreview/hidden from cache/DB, not hardcoded defaults.
|
||||
var sizeForDB int64
|
||||
if cached, ok := s.idx.GetFolderSize(folderPath); ok {
|
||||
sizeForDB = int64(cached)
|
||||
}
|
||||
hasPreview := false
|
||||
hidden := IsHidden(realPath)
|
||||
if existing, ok := s.idx.GetReducedMetadata(folderPath, true); ok && existing != nil {
|
||||
hasPreview = existing.HasPreview
|
||||
hidden = existing.Hidden
|
||||
}
|
||||
fileInfo := &iteminfo.FileInfo{
|
||||
Path: folderPath,
|
||||
ItemInfo: iteminfo.ItemInfo{
|
||||
@@ -662,8 +662,8 @@ func (s *Scanner) checkFolderModtime(folderPath string) (bool, error) {
|
||||
Size: sizeForDB,
|
||||
ModTime: info.ModTime(),
|
||||
Type: "directory",
|
||||
Hidden: false,
|
||||
HasPreview: false,
|
||||
Hidden: hidden,
|
||||
HasPreview: hasPreview,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ package indexing
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/settings"
|
||||
dbsql "github.com/gtsteffaniak/filebrowser/backend/database/sql"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/indexing/iteminfo"
|
||||
)
|
||||
|
||||
func TestPrepareScanStateInitializesMaps(t *testing.T) {
|
||||
@@ -33,3 +36,80 @@ func TestIsPathGone(t *testing.T) {
|
||||
t.Fatal("os.ErrNotExist should be path gone")
|
||||
}
|
||||
}
|
||||
|
||||
// TestCheckFolderModtime_unchangedPreservesHasPreviewAndHidden verifies quick-scan touch updates
|
||||
// do not clobber has_preview/hidden when folder modtime is unchanged.
|
||||
func TestCheckFolderModtime_unchangedPreservesHasPreviewAndHidden(t *testing.T) {
|
||||
if indexDB == nil {
|
||||
var err error
|
||||
indexDB, _, err = dbsql.NewIndexDB("test_scanner_modtime", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create test database: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
root := t.TempDir()
|
||||
photosDir := root + "/photos"
|
||||
if err := os.Mkdir(photosDir, 0o755); err != nil {
|
||||
t.Fatalf("mkdir photos: %v", err)
|
||||
}
|
||||
|
||||
idx := &Index{
|
||||
ReducedIndex: ReducedIndex{},
|
||||
Source: settings.Source{
|
||||
Name: "test_modtime",
|
||||
Path: root,
|
||||
},
|
||||
db: indexDB,
|
||||
scanUpdatedPaths: make(map[string]bool),
|
||||
folderSizes: make(map[string]uint64),
|
||||
folderSizesUnsynced: make(map[string]struct{}),
|
||||
}
|
||||
|
||||
folderPath := "/photos/"
|
||||
now := time.Now()
|
||||
stored := &iteminfo.FileInfo{
|
||||
Path: folderPath,
|
||||
ItemInfo: iteminfo.ItemInfo{
|
||||
Name: "photos",
|
||||
Type: "directory",
|
||||
Size: 42,
|
||||
ModTime: now.Add(-time.Hour),
|
||||
Hidden: true,
|
||||
HasPreview: true,
|
||||
},
|
||||
}
|
||||
if err := idx.db.InsertItem("test_modtime", folderPath, stored); err != nil {
|
||||
t.Fatalf("InsertItem: %v", err)
|
||||
}
|
||||
idx.SetFolderSize(folderPath, 42)
|
||||
|
||||
s := &Scanner{
|
||||
scanPath: "/",
|
||||
idx: idx,
|
||||
}
|
||||
s.withStatsLock(func() {
|
||||
s.lastScanned = time.Now()
|
||||
})
|
||||
s.batchItems = make([]*iteminfo.FileInfo, 0, idx.db.BatchSize)
|
||||
|
||||
changed, err := s.checkFolderModtime(folderPath)
|
||||
if err != nil {
|
||||
t.Fatalf("checkFolderModtime: %v", err)
|
||||
}
|
||||
if changed {
|
||||
t.Fatal("expected unchanged folder")
|
||||
}
|
||||
s.flushBatch()
|
||||
|
||||
got, ok := idx.GetReducedMetadata(folderPath, true)
|
||||
if !ok || got == nil {
|
||||
t.Fatal("expected folder metadata after touch update")
|
||||
}
|
||||
if !got.HasPreview {
|
||||
t.Error("HasPreview should be preserved on unchanged modtime touch update")
|
||||
}
|
||||
if !got.Hidden {
|
||||
t.Error("Hidden should be preserved on unchanged modtime touch update")
|
||||
}
|
||||
}
|
||||
@@ -213,11 +213,7 @@ func (idx *Index) runSerialScanPass() {
|
||||
paths := sortedScannerPaths(idx)
|
||||
idx.mu.Lock()
|
||||
idx.schedulerBatch++
|
||||
batchDepth := idx.schedulerBatch
|
||||
idx.mu.Unlock()
|
||||
logger.Debugf("[%s] scheduler: serialPass start paths=%d batchDepth=%d adaptive=%v",
|
||||
idx.Name, len(paths), batchDepth, idx.useAdaptiveScheduling())
|
||||
|
||||
defer func() {
|
||||
idx.mu.Lock()
|
||||
idx.schedulerBatch--
|
||||
@@ -225,7 +221,6 @@ func (idx *Index) runSerialScanPass() {
|
||||
if err := idx.PostScan(); err != nil {
|
||||
logger.Errorf("PostScan after serial pass: %v", err)
|
||||
}
|
||||
logger.Debugf("[%s] scheduler: serialPass done", idx.Name)
|
||||
}()
|
||||
|
||||
for _, p := range paths {
|
||||
@@ -334,7 +329,7 @@ func (idx *Index) runIndexScheduler() {
|
||||
for {
|
||||
now := time.Now()
|
||||
next := idx.earliestSlotWake(now)
|
||||
d := time.Until(next)
|
||||
d := time.Until(next).Truncate(time.Second)
|
||||
if d < time.Second {
|
||||
d = time.Second
|
||||
}
|
||||
|
||||
@@ -67,4 +67,5 @@ type ExtendedFileInfo struct {
|
||||
Source string `json:"source,omitempty"` // associated index source for the file
|
||||
Hash string `json:"hash,omitempty"` // hash for the file -- used for sharing
|
||||
RealPath string `json:"-"`
|
||||
PinnedItems []string `json:"pinnedItems,omitempty"` // pinned item names in this directory listing
|
||||
}
|
||||
@@ -411,20 +411,7 @@ func ShouldBubbleUpToFolderPreview(item ItemInfo) bool {
|
||||
if item.Type == "directory" || !item.HasPreview {
|
||||
return false
|
||||
}
|
||||
// Get the simple type (e.g., "image", "video", "text")
|
||||
simpleType := strings.Split(item.Type, "/")[0]
|
||||
// Text files should NOT bubble up
|
||||
if simpleType == "text" {
|
||||
return false
|
||||
}
|
||||
// Office documents should NOT bubble up
|
||||
if IsOnlyOffice(item.Name) {
|
||||
return false
|
||||
}
|
||||
// Document convertable files (PDFs, etc.) should NOT bubble up
|
||||
if HasDocConvertableExtension(item.Name, item.Type) {
|
||||
return false
|
||||
}
|
||||
// Only allow images, videos, and audio with album art to bubble up
|
||||
if simpleType == "image" || simpleType == "video" || simpleType == "audio" {
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package iteminfo
|
||||
|
||||
import "strings"
|
||||
|
||||
type namePatternMode int
|
||||
|
||||
const (
|
||||
patternLazyDefault namePatternMode = iota
|
||||
patternQuotedLiteral
|
||||
patternUserGlob
|
||||
)
|
||||
|
||||
func escapeGlobLiteral(s string) string {
|
||||
var b strings.Builder
|
||||
for _, r := range s {
|
||||
switch r {
|
||||
case '*', '?', '[', '\\':
|
||||
b.WriteByte('\\')
|
||||
b.WriteRune(r)
|
||||
default:
|
||||
b.WriteRune(r)
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func wrapGlobPattern(s string) string {
|
||||
return "*" + s + "*"
|
||||
}
|
||||
|
||||
// BuildNameGlobPattern converts a search term into a SQLite GLOB pattern for indexed file names.
|
||||
func BuildNameGlobPattern(term string, quoted, useWildcard, exactCase bool) string {
|
||||
if term == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
var mode namePatternMode
|
||||
switch {
|
||||
case useWildcard:
|
||||
mode = patternUserGlob
|
||||
case quoted:
|
||||
mode = patternQuotedLiteral
|
||||
default:
|
||||
mode = patternLazyDefault
|
||||
}
|
||||
|
||||
var pattern string
|
||||
switch mode {
|
||||
case patternUserGlob:
|
||||
pattern = term
|
||||
case patternQuotedLiteral:
|
||||
pattern = wrapGlobPattern(escapeGlobLiteral(term))
|
||||
case patternLazyDefault:
|
||||
parts := strings.Fields(term)
|
||||
if len(parts) == 0 {
|
||||
return ""
|
||||
}
|
||||
escaped := make([]string, len(parts))
|
||||
for i, p := range parts {
|
||||
escaped[i] = escapeGlobLiteral(p)
|
||||
}
|
||||
pattern = wrapGlobPattern(strings.Join(escaped, "*"))
|
||||
}
|
||||
|
||||
if !exactCase {
|
||||
pattern = strings.ToLower(pattern)
|
||||
}
|
||||
return pattern
|
||||
}
|
||||
|
||||
// NameGlobPatternsForSearch builds SQLite name GLOB patterns for the given search options.
|
||||
func NameGlobPatternsForSearch(opts SearchOptions, useWildcard, largest bool) []string {
|
||||
if largest || len(opts.Terms) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
exactCase := opts.Conditions["exact"]
|
||||
var patterns []string
|
||||
for _, t := range opts.Terms {
|
||||
if t == "" {
|
||||
continue
|
||||
}
|
||||
p := BuildNameGlobPattern(t, opts.Quoted, useWildcard, exactCase)
|
||||
if p != "" {
|
||||
patterns = append(patterns, p)
|
||||
}
|
||||
}
|
||||
if len(patterns) == 0 {
|
||||
return nil
|
||||
}
|
||||
return patterns
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package iteminfo
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBuildNameGlobPattern(t *testing.T) {
|
||||
tests := []struct {
|
||||
term string
|
||||
quoted bool
|
||||
useWildcard bool
|
||||
exactCase bool
|
||||
want string
|
||||
}{
|
||||
{"cons", false, false, false, "*cons*"},
|
||||
{"new folder", false, false, false, "*new*folder*"},
|
||||
{"new folder", true, false, false, "*new folder*"},
|
||||
{"new*folder", false, true, false, "new*folder"},
|
||||
{"Blade Runner", false, false, false, "*blade*runner*"},
|
||||
{"Blade Runner", false, false, true, "*Blade*Runner*"},
|
||||
{"test[1]", false, false, false, "*test\\[1]*"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
got := BuildNameGlobPattern(tt.term, tt.quoted, tt.useWildcard, tt.exactCase)
|
||||
if got != tt.want {
|
||||
t.Errorf("BuildNameGlobPattern(%q, quoted=%v, wildcard=%v, exact=%v) = %q, want %q",
|
||||
tt.term, tt.quoted, tt.useWildcard, tt.exactCase, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNameGlobPatternsForSearch(t *testing.T) {
|
||||
opts := SearchOptions{
|
||||
Terms: []string{"house", "car"},
|
||||
}
|
||||
patterns := NameGlobPatternsForSearch(opts, false, false)
|
||||
if len(patterns) != 2 || patterns[0] != "*house*" || patterns[1] != "*car*" {
|
||||
t.Fatalf("unexpected patterns: %#v", patterns)
|
||||
}
|
||||
|
||||
optsQuoted := SearchOptions{
|
||||
Terms: []string{"new folder"},
|
||||
Quoted: true,
|
||||
}
|
||||
patterns = NameGlobPatternsForSearch(optsQuoted, false, false)
|
||||
if len(patterns) != 1 || patterns[0] != "*new folder*" {
|
||||
t.Fatalf("unexpected quoted patterns: %#v", patterns)
|
||||
}
|
||||
|
||||
optsLargest := SearchOptions{Terms: []string{"test"}}
|
||||
if p := NameGlobPatternsForSearch(optsLargest, false, true); p != nil {
|
||||
t.Fatalf("largest mode should return nil patterns, got %#v", p)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ type SearchOptions struct {
|
||||
// MatchAllTerms, when true and non-wildcard search, an item must contain every term (AND). When false (default), any term matches (OR).
|
||||
// For name GLOB wildcard search, name must match every pattern when true; when false, patterns are OR-combined in SQL.
|
||||
MatchAllTerms bool
|
||||
// Quoted is true when the search query was a double-quoted phrase; spaces are kept literal in name matching.
|
||||
Quoted bool
|
||||
}
|
||||
|
||||
// BuildSearchOptionsFromQuery merges optional repeated literal terms (HTTP "terms" parameters) with structured filter text ("query" prefix).
|
||||
@@ -119,6 +121,7 @@ func ParseSearch(value string) SearchOptions {
|
||||
unique = strings.TrimSuffix(unique, "\"")
|
||||
|
||||
opts.Terms = []string{unique}
|
||||
opts.Quoted = true
|
||||
return opts
|
||||
}
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (idx *Index) CreateMockData(numDirs, numFilesPerDir int) {
|
||||
Files: files,
|
||||
}
|
||||
|
||||
idx.UpdateMetadata(dirInfo, nil) // nil scanner for mock
|
||||
idx.UpdateMetadata(dirInfo, nil, true) // nil scanner for mock
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-35
@@ -13,57 +13,35 @@ import (
|
||||
)
|
||||
|
||||
// UpdateMetadata persists a completed directory listing to the index. The directory row's has_preview
|
||||
// scanner is optional — if nil (API refresh), inserts run immediately; otherwise items batch until flush.
|
||||
func (idx *Index) UpdateMetadata(info *iteminfo.FileInfo, scanner *Scanner) bool {
|
||||
// reflects direct previewable children only (see GetDirInfoCore).
|
||||
func (idx *Index) UpdateMetadata(info *iteminfo.FileInfo, scanner *Scanner, persistListedFolders bool) bool {
|
||||
items := make([]*iteminfo.FileInfo, 0, len(info.Files)+len(info.Folders)+1)
|
||||
dirItem := *info
|
||||
items = append(items, &dirItem)
|
||||
|
||||
// Check if we're in a batch scan (scanner provided)
|
||||
isBatchScan := scanner != nil
|
||||
includeListedFolders := !isBatchScan || persistListedFolders
|
||||
|
||||
if isBatchScan {
|
||||
// During recursive scans: only insert directory itself and direct files
|
||||
// Subdirectories will be inserted by their own recursive indexDirectory call
|
||||
// This avoids redundant inserts and maintains the in-memory size calculation pattern
|
||||
for i := range info.Files {
|
||||
f := &info.Files[i]
|
||||
// Construct index path for the file
|
||||
filePath := strings.TrimRight(info.Path, "/") + "/" + f.Name
|
||||
|
||||
fileItem := &iteminfo.FileInfo{
|
||||
ItemInfo: f.ItemInfo,
|
||||
Path: filePath, // Store index path, not absolute path
|
||||
}
|
||||
items = append(items, fileItem)
|
||||
}
|
||||
} else {
|
||||
// Not in batch scan (e.g., API-triggered updates): insert everything
|
||||
// Add folders to the bulk insert with index paths
|
||||
if includeListedFolders {
|
||||
for i := range info.Folders {
|
||||
folder := &info.Folders[i]
|
||||
// Construct index path for the folder (with trailing slash)
|
||||
folderPath := strings.TrimRight(info.Path, "/") + "/" + folder.Name + "/"
|
||||
|
||||
folderItem := &iteminfo.FileInfo{
|
||||
ItemInfo: *folder,
|
||||
Path: folderPath, // Store index path with trailing slash
|
||||
Path: folderPath,
|
||||
}
|
||||
items = append(items, folderItem)
|
||||
}
|
||||
}
|
||||
|
||||
// Add files to the bulk insert with index paths
|
||||
for i := range info.Files {
|
||||
f := &info.Files[i]
|
||||
// Construct index path for the file
|
||||
filePath := strings.TrimRight(info.Path, "/") + "/" + f.Name
|
||||
|
||||
fileItem := &iteminfo.FileInfo{
|
||||
ItemInfo: f.ItemInfo,
|
||||
Path: filePath, // Store index path, not absolute path
|
||||
}
|
||||
items = append(items, fileItem)
|
||||
for i := range info.Files {
|
||||
f := &info.Files[i]
|
||||
filePath := strings.TrimRight(info.Path, "/") + "/" + f.Name
|
||||
fileItem := &iteminfo.FileInfo{
|
||||
ItemInfo: f.ItemInfo,
|
||||
Path: filePath,
|
||||
}
|
||||
items = append(items, fileItem)
|
||||
}
|
||||
|
||||
// Use scanner-specific batch if available
|
||||
|
||||
@@ -242,7 +242,7 @@ func TestUpdateFileMetadata(t *testing.T) {
|
||||
mock: true,
|
||||
}
|
||||
|
||||
success := index.UpdateMetadata(info, nil) // nil scanner for test
|
||||
success := index.UpdateMetadata(info, nil, true) // nil scanner for test
|
||||
if !success {
|
||||
t.Fatalf("expected UpdateFileMetadata to succeed")
|
||||
}
|
||||
@@ -315,9 +315,73 @@ func TestSetDirectoryInfo(t *testing.T) {
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "testfile.txt", ModTime: time.Now()}},
|
||||
},
|
||||
}
|
||||
index.UpdateMetadata(dir, nil) // nil scanner for test
|
||||
index.UpdateMetadata(dir, nil, true) // nil scanner for test
|
||||
storedDir, exists := index.GetMetadataInfo("/newPath/", true, false)
|
||||
if !exists || storedDir.Files[0].Name != "testfile.txt" {
|
||||
t.Fatalf("expected SetDirectoryInfo to store directory info correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateMetadata_batchScanPersistListedFolders(t *testing.T) {
|
||||
t.Parallel()
|
||||
if indexDB == nil {
|
||||
var err error
|
||||
indexDB, _, err = dbsql.NewIndexDB("test_mutate_batch", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create test database: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
index := &Index{
|
||||
Source: settings.Source{
|
||||
Name: "test_batch_folders",
|
||||
Path: "/mock/path",
|
||||
},
|
||||
db: indexDB,
|
||||
mock: true,
|
||||
}
|
||||
scanner := &Scanner{idx: index, batchItems: make([]*iteminfo.FileInfo, 0, 16)}
|
||||
|
||||
now := time.Now()
|
||||
parent := &iteminfo.FileInfo{
|
||||
Path: "/parent/",
|
||||
ItemInfo: iteminfo.ItemInfo{
|
||||
Name: "parent",
|
||||
Type: "directory",
|
||||
ModTime: now,
|
||||
},
|
||||
Folders: []iteminfo.ItemInfo{
|
||||
{
|
||||
Name: "child",
|
||||
Type: "directory",
|
||||
Size: 100,
|
||||
ModTime: now,
|
||||
HasPreview: true,
|
||||
Hidden: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
index.UpdateMetadata(parent, scanner, false)
|
||||
scanner.flushBatch()
|
||||
|
||||
_, exists := index.GetReducedMetadata("/parent/child/", true)
|
||||
if exists {
|
||||
t.Fatal("recursive batch scan should not persist listed subfolders when persistListedFolders is false")
|
||||
}
|
||||
|
||||
scanner.batchItems = scanner.batchItems[:0]
|
||||
index.UpdateMetadata(parent, scanner, true)
|
||||
scanner.flushBatch()
|
||||
|
||||
child, exists := index.GetReducedMetadata("/parent/child/", true)
|
||||
if !exists || child == nil {
|
||||
t.Fatal("expected child folder row after persistListedFolders=true batch update")
|
||||
}
|
||||
if !child.HasPreview {
|
||||
t.Error("child HasPreview should be persisted from listing")
|
||||
}
|
||||
if !child.Hidden {
|
||||
t.Error("child Hidden should be persisted from listing")
|
||||
}
|
||||
}
|
||||
+12
-27
@@ -55,10 +55,11 @@ func (idx *Index) SearchParsed(baseOpts iteminfo.SearchOptions, scope string, so
|
||||
searchOptions.Terms = []string{""}
|
||||
}
|
||||
|
||||
nameGlobPatterns := nameGlobPatternsForSearch(searchOptions, useWildcard, largest)
|
||||
globAnd := useWildcard && searchOptions.MatchAllTerms
|
||||
nameGlobPatterns := iteminfo.NameGlobPatternsForSearch(searchOptions, useWildcard, largest)
|
||||
caseExact := searchOptions.Conditions["exact"]
|
||||
globAnd := len(nameGlobPatterns) > 0 && searchOptions.MatchAllTerms
|
||||
|
||||
rows, err := idx.db.SearchItems(idx.Name, scope, largest, nameGlobPatterns, globAnd)
|
||||
rows, err := idx.db.SearchItems(idx.Name, scope, largest, nameGlobPatterns, globAnd, caseExact)
|
||||
if err != nil {
|
||||
return []*SearchResult{}
|
||||
}
|
||||
@@ -95,7 +96,7 @@ func (idx *Index) SearchParsed(baseOpts iteminfo.SearchOptions, scope string, so
|
||||
HasPreview: hasPreview,
|
||||
}
|
||||
|
||||
matches := itemMatchesSearchFilters(item, isDir, searchOptions, largest, useWildcard, nameGlobPatterns)
|
||||
matches := itemMatchesSearchFilters(item, isDir, searchOptions, largest, nameGlobPatterns)
|
||||
|
||||
if matches {
|
||||
resType := mimeType
|
||||
@@ -127,7 +128,7 @@ func (idx *Index) SearchParsed(baseOpts iteminfo.SearchOptions, scope string, so
|
||||
return sortedKeys
|
||||
}
|
||||
|
||||
func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions iteminfo.SearchOptions, largest, useWildcard bool, nameGlobPatterns []string) bool {
|
||||
func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions iteminfo.SearchOptions, largest bool, nameGlobPatterns []string) bool {
|
||||
if largest {
|
||||
largerThan := int64(searchOptions.LargerThan) * 1024 * 1024
|
||||
sizeMatches := largerThan == 0 || item.Size > largerThan
|
||||
@@ -141,7 +142,7 @@ func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions
|
||||
dateMatches := searchDateMatches(item.ModTime.Unix(), searchOptions)
|
||||
return sizeMatches && typeMatches && dateMatches
|
||||
}
|
||||
if useWildcard && len(nameGlobPatterns) > 0 {
|
||||
if len(nameGlobPatterns) > 0 {
|
||||
return item.MatchesSearchAuxiliaryFilters(searchOptions)
|
||||
}
|
||||
if searchOptions.MatchAllTerms {
|
||||
@@ -168,23 +169,6 @@ func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions
|
||||
return false
|
||||
}
|
||||
|
||||
// nameGlobPatternsForSearch builds non-empty parsed terms for SQLite name GLOB OR clauses.
|
||||
func nameGlobPatternsForSearch(opts iteminfo.SearchOptions, useWildcard, largest bool) []string {
|
||||
if largest || !useWildcard || len(opts.Terms) == 0 {
|
||||
return nil
|
||||
}
|
||||
var patterns []string
|
||||
for _, t := range opts.Terms {
|
||||
if t != "" {
|
||||
patterns = append(patterns, t)
|
||||
}
|
||||
}
|
||||
if len(patterns) == 0 {
|
||||
return nil
|
||||
}
|
||||
return patterns
|
||||
}
|
||||
|
||||
func searchDateMatches(modUnix int64, opts iteminfo.SearchOptions) bool {
|
||||
if opts.ModifiedNewerThan > 0 && modUnix < opts.ModifiedNewerThan {
|
||||
return false
|
||||
@@ -234,10 +218,11 @@ func SearchMultiSourcesParsed(baseOpts iteminfo.SearchOptions, sources []string,
|
||||
searchOptions.Terms = []string{""}
|
||||
}
|
||||
|
||||
nameGlobPatterns := nameGlobPatternsForSearch(searchOptions, useWildcard, largest)
|
||||
globAnd := useWildcard && searchOptions.MatchAllTerms
|
||||
nameGlobPatterns := iteminfo.NameGlobPatternsForSearch(searchOptions, useWildcard, largest)
|
||||
caseExact := searchOptions.Conditions["exact"]
|
||||
globAnd := len(nameGlobPatterns) > 0 && searchOptions.MatchAllTerms
|
||||
|
||||
rows, err := db.SearchItemsMultiSource(sources, normalizedScopes, largest, nameGlobPatterns, globAnd)
|
||||
rows, err := db.SearchItemsMultiSource(sources, normalizedScopes, largest, nameGlobPatterns, globAnd, caseExact)
|
||||
if err != nil {
|
||||
return []*SearchResult{}
|
||||
}
|
||||
@@ -275,7 +260,7 @@ func SearchMultiSourcesParsed(baseOpts iteminfo.SearchOptions, sources []string,
|
||||
HasPreview: hasPreview,
|
||||
}
|
||||
|
||||
matches := itemMatchesSearchFilters(item, isDir, searchOptions, largest, useWildcard, nameGlobPatterns)
|
||||
matches := itemMatchesSearchFilters(item, isDir, searchOptions, largest, nameGlobPatterns)
|
||||
|
||||
if matches {
|
||||
resType := mimeType
|
||||
|
||||
@@ -116,6 +116,14 @@ func TestParseSearch(t *testing.T) {
|
||||
Terms: []string{"thisfile"},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: `"new folder"`,
|
||||
want: iteminfo.SearchOptions{
|
||||
Conditions: map[string]bool{"exact": false},
|
||||
Terms: []string{"new folder"},
|
||||
Quoted: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
input: "type:olderThan=2024-06-01 type:newerThan=2024-01-01 findme",
|
||||
want: iteminfo.SearchOptions{
|
||||
@@ -266,6 +274,13 @@ func TestSearchIndexes(t *testing.T) {
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "toggle.gif", Size: 65536, Type: "image/gif"}},
|
||||
},
|
||||
},
|
||||
"/media/": {
|
||||
ItemInfo: iteminfo.ItemInfo{Name: "media", Type: "directory"},
|
||||
Files: []iteminfo.ExtendedItemInfo{
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "Blade.Runner.mkv", Type: "video"}},
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "new.folder.txt", Type: "text"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Insert all directories and files into database
|
||||
@@ -462,6 +477,65 @@ func TestSearchIndexes(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
search: "Blade Runner",
|
||||
scope: "/media/",
|
||||
expectedResult: []*SearchResult{
|
||||
{
|
||||
Path: "/media/Blade.Runner.mkv",
|
||||
Type: "video",
|
||||
Size: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
search: "new folder",
|
||||
scope: "/media/",
|
||||
expectedResult: []*SearchResult{
|
||||
{
|
||||
Path: "/media/new.folder.txt",
|
||||
Type: "text",
|
||||
Size: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
search: "new folder",
|
||||
scope: "/",
|
||||
expectedResult: []*SearchResult{
|
||||
{
|
||||
Path: "/new+folder/",
|
||||
Type: "directory",
|
||||
Size: 0,
|
||||
},
|
||||
{
|
||||
Path: "/media/new.folder.txt",
|
||||
Type: "text",
|
||||
Size: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
search: `"new folder"`,
|
||||
scope: "/media/",
|
||||
expectedResult: []*SearchResult{},
|
||||
},
|
||||
{
|
||||
search: "VIDEO",
|
||||
scope: "/new/test/",
|
||||
expectedResult: []*SearchResult{
|
||||
{
|
||||
Path: "/new/test/video.MP4",
|
||||
Type: "video",
|
||||
Size: 0,
|
||||
},
|
||||
{
|
||||
Path: "/new/test/video.mp4",
|
||||
Type: "video",
|
||||
Size: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -481,6 +555,59 @@ func TestSearchIndexes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchUserGlob(t *testing.T) {
|
||||
if indexDB == nil {
|
||||
var err error
|
||||
indexDB, _, err = dbsql.NewIndexDB("test_search_glob", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create test database: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
index := Index{
|
||||
Source: settings.Source{
|
||||
Name: "test_search_glob",
|
||||
Path: "/mock/path",
|
||||
},
|
||||
db: indexDB,
|
||||
mock: true,
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
directories := map[string]*iteminfo.FileInfo{
|
||||
"/media/": {
|
||||
ItemInfo: iteminfo.ItemInfo{Name: "media", Type: "directory"},
|
||||
Files: []iteminfo.ExtendedItemInfo{
|
||||
{ItemInfo: iteminfo.ItemInfo{Name: "NEW-folder", Type: "text"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for path, dirInfo := range directories {
|
||||
dirInfo.Path = path
|
||||
if dirInfo.ModTime.IsZero() {
|
||||
dirInfo.ModTime = now
|
||||
}
|
||||
_ = index.db.InsertItem("test_search_glob", path, dirInfo)
|
||||
for _, file := range dirInfo.Files {
|
||||
filePath := strings.TrimSuffix(path, "/") + "/" + file.Name
|
||||
fileInfo := &iteminfo.FileInfo{
|
||||
Path: filePath,
|
||||
ItemInfo: file.ItemInfo,
|
||||
}
|
||||
if fileInfo.ModTime.IsZero() {
|
||||
fileInfo.ModTime = now
|
||||
}
|
||||
_ = index.db.InsertItem("test_search_glob", filePath, fileInfo)
|
||||
}
|
||||
}
|
||||
|
||||
result := index.Search("new*folder", "/media/", "", false, DefaultSearchResults, 0, 0, true)
|
||||
if len(result) != 1 || result[0].Path != "/media/NEW-folder" {
|
||||
t.Fatalf("expected new*folder to match NEW-folder, got %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchLargestModeExcludesRoot(t *testing.T) {
|
||||
// Initialize the database if not already done
|
||||
if indexDB == nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package preview
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
@@ -12,6 +13,22 @@ import (
|
||||
"github.com/kovidgoyal/imaging"
|
||||
)
|
||||
|
||||
// configureImagingParallelism limits kovidgoyal/imaging to one thread per resize.
|
||||
// Concurrent preview jobs are capped separately by imageSem (like OG filebrowser).
|
||||
func configureImagingParallelism() {
|
||||
imaging.SetMaxProcs(1)
|
||||
}
|
||||
|
||||
// previewDecodeOpts returns decode options tuned for thumbnails: skip ICC/sRGB conversion
|
||||
// (not needed for previews) and optionally apply EXIF orientation.
|
||||
func previewDecodeOpts(autoOrient bool) []imaging.DecodeOption {
|
||||
opts := []imaging.DecodeOption{imaging.ColorSpace(imaging.NO_CHANGE_OF_COLORSPACE)}
|
||||
if autoOrient {
|
||||
opts = append(opts, imaging.AutoOrientation(true))
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
// Format is an image file format.
|
||||
/*
|
||||
ENUM(
|
||||
@@ -150,12 +167,26 @@ type ResizeOptions struct {
|
||||
JpegQuality int // JPEG encoding quality (1-100), 0 means use Quality default
|
||||
}
|
||||
|
||||
func (s *Service) Resize(in io.Reader, out io.Writer, opts ResizeOptions) error {
|
||||
return s.ResizeWithSize(in, out, 0, opts)
|
||||
func (s *Service) Resize(ctx context.Context, in io.Reader, out io.Writer, opts ResizeOptions) error {
|
||||
return s.ResizeWithSize(ctx, in, out, 0, opts)
|
||||
}
|
||||
|
||||
// ResizeWithSize resizes an image with file size information for appropriate semaphore selection
|
||||
func (s *Service) ResizeWithSize(in io.Reader, out io.Writer, fileSize int64, opts ResizeOptions) error {
|
||||
// ResizeWithSize resizes an image with file size information for appropriate semaphore selection.
|
||||
// Resize runs synchronously so the image semaphore accurately bounds concurrent CPU work.
|
||||
// A detached goroutine would return on ctx cancellation while still decoding/resizing,
|
||||
// defeating the semaphore and piling up orphaned work that causes preview timeouts under load.
|
||||
func (s *Service) ResizeWithSize(ctx context.Context, in io.Reader, out io.Writer, fileSize int64, opts ResizeOptions) error {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
err := s.resizeWithSize(in, out, fileSize, opts)
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Service) resizeWithSize(in io.Reader, out io.Writer, fileSize int64, opts ResizeOptions) error {
|
||||
// Set defaults
|
||||
if opts.ResizeMode == 0 {
|
||||
opts.ResizeMode = ResizeModeFit
|
||||
@@ -193,7 +224,7 @@ func (s *Service) ResizeWithSize(in io.Reader, out io.Writer, fileSize int64, op
|
||||
}
|
||||
|
||||
// Decode the image - try imaging library first, fall back to format-specific decoder if it fails
|
||||
img, err := imaging.Decode(wrappedReader, imaging.AutoOrientation(true))
|
||||
img, err := imaging.Decode(wrappedReader, previewDecodeOpts(true)...)
|
||||
if err != nil {
|
||||
// Imaging library failed, try format-specific standard decoder as fallback
|
||||
// Reset reader if possible
|
||||
@@ -217,7 +248,16 @@ func (s *Service) ResizeWithSize(in io.Reader, out io.Writer, fileSize int64, op
|
||||
}
|
||||
}
|
||||
|
||||
// Resize
|
||||
// Skip resize in Fit mode when the image is already within target dimensions.
|
||||
// Fill mode may still need to upscale or crop to reach the target size.
|
||||
bounds := img.Bounds()
|
||||
if opts.ResizeMode != ResizeModeFill && bounds.Dx() <= opts.Width && bounds.Dy() <= opts.Height {
|
||||
if opts.Format == FormatJpeg {
|
||||
return jpeg.Encode(out, img, &jpeg.Options{Quality: opts.JpegQuality})
|
||||
}
|
||||
return imaging.Encode(out, img, opts.Format.toImaging())
|
||||
}
|
||||
|
||||
resampleFilter := opts.Quality.resampleFilter()
|
||||
switch opts.ResizeMode {
|
||||
case ResizeModeFill:
|
||||
@@ -242,7 +282,7 @@ func applyOrientationToPreviewBytes(imageBytes []byte, orientation string) []byt
|
||||
if len(imageBytes) < 100 {
|
||||
return imageBytes
|
||||
}
|
||||
img, err := imaging.Decode(bytes.NewReader(imageBytes))
|
||||
img, err := imaging.Decode(bytes.NewReader(imageBytes), previewDecodeOpts(false)...)
|
||||
if err != nil {
|
||||
return imageBytes
|
||||
}
|
||||
@@ -268,7 +308,7 @@ func applyOrientationToPreviewBytes(imageBytes []byte, orientation string) []byt
|
||||
return imageBytes
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := jpeg.Encode(&buf, out, &jpeg.Options{Quality: 90}); err != nil {
|
||||
if err := jpeg.Encode(&buf, out, &jpeg.Options{Quality: 80}); err != nil {
|
||||
return imageBytes
|
||||
}
|
||||
return buf.Bytes()
|
||||
@@ -357,6 +397,6 @@ func CreateThumbnail(rawData io.Reader, width, height int) (image.Image, error)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode image: %w", err)
|
||||
}
|
||||
thumb := imaging.Fit(img, width, height, imaging.Lanczos)
|
||||
thumb := imaging.Fit(img, width, height, imaging.CatmullRom)
|
||||
return thumb, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package preview
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"image"
|
||||
"image/gif"
|
||||
@@ -247,7 +248,7 @@ func TestService_Resize(t *testing.T) {
|
||||
defer source.Close()
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
err := svc.Resize(source, buf, test.options)
|
||||
err := svc.Resize(context.Background(), source, buf, test.options)
|
||||
if (err != nil) != test.wantErr {
|
||||
t.Fatalf("GetMarketSpecs() error = %v, wantErr %v", err, test.wantErr)
|
||||
}
|
||||
@@ -459,7 +460,7 @@ func TestResize_ConcurrencyLimit(t *testing.T) {
|
||||
source := newGrayJpeg(t, 100, 100)
|
||||
defer source.Close()
|
||||
out := &bytes.Buffer{}
|
||||
err := svc.Resize(source, out, ResizeOptions{Width: 50, Height: 50})
|
||||
err := svc.Resize(context.Background(), source, out, ResizeOptions{Width: 50, Height: 50})
|
||||
require.NoError(t, err)
|
||||
require.Greater(t, out.Len(), 0)
|
||||
}
|
||||
@@ -473,7 +474,7 @@ func TestResize_ConcurrencyLimit_NoFFmpeg(t *testing.T) {
|
||||
source := newGrayJpeg(t, 100, 100)
|
||||
defer source.Close()
|
||||
out := &bytes.Buffer{}
|
||||
err := svc.Resize(source, out, ResizeOptions{Width: 50, Height: 50})
|
||||
err := svc.Resize(context.Background(), source, out, ResizeOptions{Width: 50, Height: 50})
|
||||
require.NoError(t, err)
|
||||
require.Greater(t, out.Len(), 0)
|
||||
}
|
||||
@@ -494,12 +495,47 @@ func TestCreatePreviewFromReader_UsesConcurrencyLimit(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create preview from reader
|
||||
out, err := svc.CreatePreview(bytes.NewReader(data), int64(len(data)), options)
|
||||
out, err := svc.CreatePreview(context.Background(), bytes.NewReader(data), int64(len(data)), options)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, out)
|
||||
|
||||
// Same via another call for parity
|
||||
out2, err := svc.CreatePreview(bytes.NewReader(data), int64(len(data)), options)
|
||||
out2, err := svc.CreatePreview(context.Background(), bytes.NewReader(data), int64(len(data)), options)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, out, out2)
|
||||
}
|
||||
|
||||
func TestImageFitsPreviewSize(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
width int
|
||||
height int
|
||||
previewSize string
|
||||
want bool
|
||||
}{
|
||||
{name: "fits xlarge", width: 800, height: 600, previewSize: "xlarge", want: true},
|
||||
{name: "exceeds xlarge width", width: 1200, height: 600, previewSize: "xlarge", want: false},
|
||||
{name: "fits large", width: 640, height: 480, previewSize: "large", want: true},
|
||||
{name: "fits small", width: 256, height: 200, previewSize: "small", want: true},
|
||||
{name: "exceeds small height", width: 200, height: 300, previewSize: "small", want: false},
|
||||
{name: "original always fits", width: 5000, height: 5000, previewSize: "original", want: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.Equal(t, tt.want, ImageFitsPreviewSize(tt.width, tt.height, tt.previewSize))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadImageFileDimensions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
width, height, err := ReadImageFileDimensions("testdata/gray-sample.jpg")
|
||||
require.NoError(t, err)
|
||||
require.Greater(t, width, 0)
|
||||
require.Greater(t, height, 0)
|
||||
}
|
||||
@@ -87,14 +87,17 @@ func (s *Service) GenerateOfficePreview(ctx context.Context, filetype, key, titl
|
||||
return data, fmt.Errorf("error from OnlyOffice: %s", response.Error)
|
||||
}
|
||||
|
||||
// make get request to binary data response.FileURL and return the body as a byte array data
|
||||
resp, err = http.Get(response.FileURL)
|
||||
thumbReq, err := http.NewRequestWithContext(ctx, http.MethodGet, response.FileURL, nil)
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return data, fmt.Errorf("failed to get preview file, status code: %d", resp.StatusCode)
|
||||
thumbResp, err := client.Do(thumbReq)
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
return io.ReadAll(resp.Body)
|
||||
defer thumbResp.Body.Close()
|
||||
if thumbResp.StatusCode != http.StatusOK {
|
||||
return data, fmt.Errorf("failed to get preview file, status code: %d", thumbResp.StatusCode)
|
||||
}
|
||||
return io.ReadAll(thumbResp.Body)
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -49,6 +50,8 @@ type Service struct {
|
||||
// 3-6 processors: 2 large, rest small
|
||||
// 7+ processors: 3 large, rest small
|
||||
func NewPreviewGenerator(concurrencyLimit int, cacheDir string) *Service {
|
||||
configureImagingParallelism()
|
||||
|
||||
if concurrencyLimit < 1 {
|
||||
concurrencyLimit = 1
|
||||
}
|
||||
@@ -342,6 +345,13 @@ func (s *Service) generateVideoPreviewBytes(ctx context.Context, file iteminfo.E
|
||||
|
||||
// generateImagePreview generates preview for regular image files
|
||||
func (s *Service) generateImagePreview(ctx context.Context, file iteminfo.ExtendedFileInfo, previewSize string) ([]byte, error) {
|
||||
const maxSizeForOriginal = 256 * 1024 // 256KB
|
||||
if previewSize != "original" && (file.Size < maxSizeForOriginal || ShouldServeOriginalImage(file.RealPath, previewSize)) {
|
||||
if original, err := os.ReadFile(file.RealPath); err == nil {
|
||||
return original, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Stream from file instead of os.ReadFile so we don't load every image fully into memory
|
||||
f, err := os.Open(file.RealPath)
|
||||
if err != nil {
|
||||
@@ -355,8 +365,11 @@ func (s *Service) generateImagePreview(ctx context.Context, file iteminfo.Extend
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imageBytes, err := s.CreatePreview(f, file.Size, options)
|
||||
imageBytes, err := s.CreatePreview(ctx, f, file.Size, options)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
// For JPEG files, try FFmpeg fallback if initial decode failed
|
||||
if strings.HasPrefix(file.Type, "image/jpeg") {
|
||||
return handleJPEGFallback(ctx, s, file, previewSize, err)
|
||||
@@ -496,8 +509,18 @@ func GeneratePreviewWithMD5(ctx context.Context, file iteminfo.ExtendedFileInfo,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resizedBytes, err := service.CreatePreview(bytes.NewReader(imageBytes), 0, options)
|
||||
if cfg, _, cfgErr := image.DecodeConfig(bytes.NewReader(imageBytes)); cfgErr == nil && ImageFitsPreviewSize(cfg.Width, cfg.Height, previewSize) {
|
||||
if err = service.fileCache.Store(ctx, cacheKey, imageBytes); err != nil {
|
||||
logger.Errorf("failed to cache image: %v", err)
|
||||
}
|
||||
return imageBytes, nil
|
||||
}
|
||||
|
||||
resizedBytes, err := service.CreatePreview(ctx, bytes.NewReader(imageBytes), 0, options)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
// For JPEG files, try FFmpeg fallback if resize failed
|
||||
if strings.HasPrefix(file.Type, "image/jpeg") {
|
||||
resizedBytes, err = handleJPEGFallback(ctx, service, file, previewSize, err)
|
||||
@@ -533,6 +556,42 @@ func GeneratePreview(ctx context.Context, file iteminfo.ExtendedFileInfo, previe
|
||||
return GeneratePreviewWithMD5(ctx, file, previewSize, officeUrl, seekPercentage, cacheHash)
|
||||
}
|
||||
|
||||
// ImageFitsPreviewSize reports whether both image dimensions are within the preview bounds.
|
||||
func ImageFitsPreviewSize(imgWidth, imgHeight int, previewSize string) bool {
|
||||
if previewSize == "original" {
|
||||
return true
|
||||
}
|
||||
opts, err := getPreviewOptions(previewSize)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return imgWidth <= opts.Width && imgHeight <= opts.Height
|
||||
}
|
||||
|
||||
// ReadImageFileDimensions reads image width and height without decoding the full image.
|
||||
func ReadImageFileDimensions(path string) (int, int, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
cfg, _, err := image.DecodeConfig(f)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return cfg.Width, cfg.Height, nil
|
||||
}
|
||||
|
||||
// ShouldServeOriginalImage reports whether an on-disk image is already within preview bounds.
|
||||
func ShouldServeOriginalImage(path, previewSize string) bool {
|
||||
width, height, err := ReadImageFileDimensions(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return ImageFitsPreviewSize(width, height, previewSize)
|
||||
}
|
||||
|
||||
// getPreviewOptions returns resize options for the given preview size
|
||||
func getPreviewOptions(previewSize string) (ResizeOptions, error) {
|
||||
switch previewSize {
|
||||
@@ -549,15 +608,15 @@ func getPreviewOptions(previewSize string) (ResizeOptions, error) {
|
||||
Width: 640,
|
||||
Height: 640,
|
||||
ResizeMode: ResizeModeFit,
|
||||
Quality: QualityHigh,
|
||||
Quality: QualityMedium,
|
||||
Format: FormatJpeg,
|
||||
}, nil
|
||||
case "small":
|
||||
return ResizeOptions{
|
||||
Width: 256,
|
||||
Height: 256,
|
||||
ResizeMode: ResizeModeFit,
|
||||
Quality: QualityMedium,
|
||||
ResizeMode: ResizeModeFill,
|
||||
Quality: QualityLow,
|
||||
Format: FormatJpeg,
|
||||
}, nil
|
||||
default:
|
||||
@@ -566,9 +625,9 @@ func getPreviewOptions(previewSize string) (ResizeOptions, error) {
|
||||
}
|
||||
|
||||
// CreatePreview resizes an image from a reader with the given options
|
||||
func (s *Service) CreatePreview(reader io.Reader, fileSize int64, options ResizeOptions) ([]byte, error) {
|
||||
func (s *Service) CreatePreview(ctx context.Context, reader io.Reader, fileSize int64, options ResizeOptions) ([]byte, error) {
|
||||
output := &bytes.Buffer{}
|
||||
if err := s.ResizeWithSize(reader, output, fileSize, options); err != nil {
|
||||
if err := s.ResizeWithSize(ctx, reader, output, fileSize, options); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return output.Bytes(), nil
|
||||
|
||||
@@ -3600,6 +3600,70 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/users/pinnedItems": {
|
||||
"patch": {
|
||||
"description": "Patches one pinned item at a time. Defaults to add; pass ?action=remove to unpin.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Add or remove a pinned item",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "add (default) or remove",
|
||||
"name": "action",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"description": "Pinned item",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/http.pinnedItemPatchRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"description": "Returns the health status of the API.",
|
||||
@@ -4566,6 +4630,86 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/public/api/share/pinnedItems": {
|
||||
"patch": {
|
||||
"description": "Patches one pinned item at a time for share owners. Defaults to add; pass ?action=remove to unpin.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Shares"
|
||||
],
|
||||
"summary": "Add or remove a pinned item on a share",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Share hash",
|
||||
"name": "hash",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "add (default) or remove",
|
||||
"name": "action",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"description": "Pinned item",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/http.sharePinnedItemPatchRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Share not found",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@@ -4859,6 +5003,9 @@ const docTemplate = `{
|
||||
"perUserDownloadLimit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/share.PinnedItems"
|
||||
},
|
||||
"quickDownload": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -5034,6 +5181,44 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.pinnedItemPatchRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"path",
|
||||
"source"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "item basename within path",
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"description": "scope-relative parent directory",
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.sharePinnedItemPatchRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"path"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "item basename within path",
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"description": "share-relative parent directory",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.unarchiveRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5150,6 +5335,13 @@ const docTemplate = `{
|
||||
"description": "path scoped to the associated index",
|
||||
"type": "string"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"description": "pinned item names in this directory listing",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"size": {
|
||||
"description": "length in bytes for regular files",
|
||||
"type": "integer"
|
||||
@@ -6147,7 +6339,7 @@ const docTemplate = `{
|
||||
"type": "integer"
|
||||
},
|
||||
"numImageProcessors": {
|
||||
"description": "number of concurrent image processing jobs used to create previews, default is number of cpu cores available.",
|
||||
"description": "number of concurrent image processing jobs used to create previews, default is 4.",
|
||||
"type": "integer"
|
||||
},
|
||||
"port": {
|
||||
@@ -6155,7 +6347,7 @@ const docTemplate = `{
|
||||
"type": "integer"
|
||||
},
|
||||
"socket": {
|
||||
"description": "socket to listen on",
|
||||
"description": "socket to listen on - eg. /var/run/filebrowser.sock",
|
||||
"type": "string"
|
||||
},
|
||||
"sources": {
|
||||
@@ -7191,6 +7383,9 @@ const docTemplate = `{
|
||||
"perUserDownloadLimit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/share.PinnedItems"
|
||||
},
|
||||
"quickDownload": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -7251,6 +7446,15 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"share.PinnedItems": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.AuthToken": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -7349,6 +7553,18 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.PinnedItems": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.Preview": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -7577,6 +7793,9 @@ const docTemplate = `{
|
||||
"permissions": {
|
||||
"$ref": "#/definitions/users.Permissions"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/users.PinnedItems"
|
||||
},
|
||||
"preferEditorForMarkdown": {
|
||||
"description": "prefer editor first for markdown files instead of the Markdown Viewer",
|
||||
"type": "boolean"
|
||||
|
||||
@@ -3589,6 +3589,70 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/users/pinnedItems": {
|
||||
"patch": {
|
||||
"description": "Patches one pinned item at a time. Defaults to add; pass ?action=remove to unpin.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Add or remove a pinned item",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "add (default) or remove",
|
||||
"name": "action",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"description": "Pinned item",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/http.pinnedItemPatchRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"description": "Returns the health status of the API.",
|
||||
@@ -4555,6 +4619,86 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/public/api/share/pinnedItems": {
|
||||
"patch": {
|
||||
"description": "Patches one pinned item at a time for share owners. Defaults to add; pass ?action=remove to unpin.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Shares"
|
||||
],
|
||||
"summary": "Add or remove a pinned item on a share",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Share hash",
|
||||
"name": "hash",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "add (default) or remove",
|
||||
"name": "action",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"description": "Pinned item",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/http.sharePinnedItemPatchRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Share not found",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@@ -4848,6 +4992,9 @@
|
||||
"perUserDownloadLimit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/share.PinnedItems"
|
||||
},
|
||||
"quickDownload": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -5023,6 +5170,44 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.pinnedItemPatchRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"path",
|
||||
"source"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "item basename within path",
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"description": "scope-relative parent directory",
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.sharePinnedItemPatchRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"path"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "item basename within path",
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"description": "share-relative parent directory",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"http.unarchiveRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5139,6 +5324,13 @@
|
||||
"description": "path scoped to the associated index",
|
||||
"type": "string"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"description": "pinned item names in this directory listing",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"size": {
|
||||
"description": "length in bytes for regular files",
|
||||
"type": "integer"
|
||||
@@ -6136,7 +6328,7 @@
|
||||
"type": "integer"
|
||||
},
|
||||
"numImageProcessors": {
|
||||
"description": "number of concurrent image processing jobs used to create previews, default is number of cpu cores available.",
|
||||
"description": "number of concurrent image processing jobs used to create previews, default is 4.",
|
||||
"type": "integer"
|
||||
},
|
||||
"port": {
|
||||
@@ -6144,7 +6336,7 @@
|
||||
"type": "integer"
|
||||
},
|
||||
"socket": {
|
||||
"description": "socket to listen on",
|
||||
"description": "socket to listen on - eg. /var/run/filebrowser.sock",
|
||||
"type": "string"
|
||||
},
|
||||
"sources": {
|
||||
@@ -7180,6 +7372,9 @@
|
||||
"perUserDownloadLimit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/share.PinnedItems"
|
||||
},
|
||||
"quickDownload": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -7240,6 +7435,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"share.PinnedItems": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.AuthToken": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -7338,6 +7542,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.PinnedItems": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"users.Preview": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -7566,6 +7782,9 @@
|
||||
"permissions": {
|
||||
"$ref": "#/definitions/users.Permissions"
|
||||
},
|
||||
"pinnedItems": {
|
||||
"$ref": "#/definitions/users.PinnedItems"
|
||||
},
|
||||
"preferEditorForMarkdown": {
|
||||
"description": "prefer editor first for markdown files instead of the Markdown Viewer",
|
||||
"type": "boolean"
|
||||
|
||||
@@ -193,6 +193,8 @@ definitions:
|
||||
type: boolean
|
||||
perUserDownloadLimit:
|
||||
type: boolean
|
||||
pinnedItems:
|
||||
$ref: '#/definitions/share.PinnedItems'
|
||||
quickDownload:
|
||||
type: boolean
|
||||
shareTheme:
|
||||
@@ -324,6 +326,33 @@ definitions:
|
||||
- $ref: '#/definitions/http.fileWatchMetadata'
|
||||
description: File metadata for non-text files
|
||||
type: object
|
||||
http.pinnedItemPatchRequest:
|
||||
properties:
|
||||
name:
|
||||
description: item basename within path
|
||||
type: string
|
||||
path:
|
||||
description: scope-relative parent directory
|
||||
type: string
|
||||
source:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- path
|
||||
- source
|
||||
type: object
|
||||
http.sharePinnedItemPatchRequest:
|
||||
properties:
|
||||
name:
|
||||
description: item basename within path
|
||||
type: string
|
||||
path:
|
||||
description: share-relative parent directory
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- path
|
||||
type: object
|
||||
http.unarchiveRequest:
|
||||
properties:
|
||||
deleteAfter:
|
||||
@@ -410,6 +439,11 @@ definitions:
|
||||
path:
|
||||
description: path scoped to the associated index
|
||||
type: string
|
||||
pinnedItems:
|
||||
description: pinned item names in this directory listing
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
size:
|
||||
description: length in bytes for regular files
|
||||
type: integer
|
||||
@@ -1180,13 +1214,13 @@ definitions:
|
||||
type: integer
|
||||
numImageProcessors:
|
||||
description: number of concurrent image processing jobs used to create previews,
|
||||
default is number of cpu cores available.
|
||||
default is 4.
|
||||
type: integer
|
||||
port:
|
||||
description: port to listen on
|
||||
type: integer
|
||||
socket:
|
||||
description: socket to listen on
|
||||
description: socket to listen on - eg. /var/run/filebrowser.sock
|
||||
type: string
|
||||
sources:
|
||||
items:
|
||||
@@ -1947,6 +1981,8 @@ definitions:
|
||||
type: string
|
||||
perUserDownloadLimit:
|
||||
type: boolean
|
||||
pinnedItems:
|
||||
$ref: '#/definitions/share.PinnedItems'
|
||||
quickDownload:
|
||||
type: boolean
|
||||
shareTheme:
|
||||
@@ -1993,6 +2029,12 @@ definitions:
|
||||
"gallery"'
|
||||
type: string
|
||||
type: object
|
||||
share.PinnedItems:
|
||||
additionalProperties:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
users.AuthToken:
|
||||
properties:
|
||||
Permissions:
|
||||
@@ -2063,6 +2105,14 @@ definitions:
|
||||
description: allow sharing files
|
||||
type: boolean
|
||||
type: object
|
||||
users.PinnedItems:
|
||||
additionalProperties:
|
||||
additionalProperties:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
users.Preview:
|
||||
properties:
|
||||
audio:
|
||||
@@ -2227,6 +2277,8 @@ definitions:
|
||||
description: legacy for migration purposes... og filebrowser has perm attribute
|
||||
permissions:
|
||||
$ref: '#/definitions/users.Permissions'
|
||||
pinnedItems:
|
||||
$ref: '#/definitions/users.PinnedItems'
|
||||
preferEditorForMarkdown:
|
||||
description: prefer editor first for markdown files instead of the Markdown
|
||||
Viewer
|
||||
@@ -4846,6 +4898,49 @@ paths:
|
||||
summary: Update a user's details
|
||||
tags:
|
||||
- Users
|
||||
/api/users/pinnedItems:
|
||||
patch:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Patches one pinned item at a time. Defaults to add; pass ?action=remove
|
||||
to unpin.
|
||||
parameters:
|
||||
- description: add (default) or remove
|
||||
in: query
|
||||
name: action
|
||||
type: string
|
||||
- description: Pinned item
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/http.pinnedItemPatchRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"403":
|
||||
description: Forbidden
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
summary: Add or remove a pinned item
|
||||
tags:
|
||||
- Users
|
||||
/health:
|
||||
get:
|
||||
consumes:
|
||||
@@ -5514,4 +5609,58 @@ paths:
|
||||
summary: Get share information by hash
|
||||
tags:
|
||||
- Shares
|
||||
/public/api/share/pinnedItems:
|
||||
patch:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Patches one pinned item at a time for share owners. Defaults to
|
||||
add; pass ?action=remove to unpin.
|
||||
parameters:
|
||||
- description: Share hash
|
||||
in: query
|
||||
name: hash
|
||||
required: true
|
||||
type: string
|
||||
- description: add (default) or remove
|
||||
in: query
|
||||
name: action
|
||||
type: string
|
||||
- description: Pinned item
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/http.sharePinnedItemPatchRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"403":
|
||||
description: Forbidden
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"404":
|
||||
description: Share not found
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
summary: Add or remove a pinned item on a share
|
||||
tags:
|
||||
- Shares
|
||||
swagger: "2.0"
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/vue3-essential",
|
||||
"eslint:recommended",
|
||||
"@vue/eslint-config-typescript",
|
||||
"plugin:@intlify/vue-i18n/recommended"
|
||||
],
|
||||
"settings": {
|
||||
"vue-i18n": {
|
||||
"localeDir": "./src/i18n/en.json",
|
||||
"messageSyntaxVersion": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-unreachable": "off",
|
||||
// vue-i18n rules:
|
||||
// This rule will check if the key used in $t() exists in your locale messages.
|
||||
// The localeDir setting above points to en.json as the single source of truth.
|
||||
"@intlify/vue-i18n/no-missing-keys": "error",
|
||||
// Check for unused keys in en.json (keys that exist but are never used in code)
|
||||
"@intlify/vue-i18n/no-unused-keys": [
|
||||
"error",
|
||||
{
|
||||
"src": "./src",
|
||||
"extensions": [".js", ".vue", ".ts"]
|
||||
}
|
||||
],
|
||||
|
||||
"@intlify/vue-i18n/no-raw-text": [
|
||||
"error",
|
||||
{
|
||||
"ignoreNodes": ["i", "v-icon"]
|
||||
}
|
||||
],
|
||||
|
||||
// If you have your sync script, you might not need this one for other locales.
|
||||
"@intlify/vue-i18n/no-missing-keys-in-other-locales": "off",
|
||||
"vue/multi-word-component-names": "off",
|
||||
"vue/no-mutating-props": [
|
||||
"error",
|
||||
{
|
||||
"shallowOnly": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import { defineConfig } from "eslint/config";
|
||||
import js from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import vueI18n from '@intlify/eslint-plugin-vue-i18n';
|
||||
import vueParser from "vue-eslint-parser";
|
||||
import globals from "globals";
|
||||
import security from "eslint-plugin-security";
|
||||
|
||||
export default defineConfig(
|
||||
{
|
||||
ignores: [
|
||||
"**/dist/**",
|
||||
"**/node_modules/**",
|
||||
"**/public/**",
|
||||
"**/*.json",
|
||||
],
|
||||
},
|
||||
|
||||
// Defaults
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...pluginVue.configs["flat/essential"],
|
||||
...vueI18n.configs.recommended,
|
||||
security.configs.recommended,
|
||||
|
||||
// i18n
|
||||
{
|
||||
settings: {
|
||||
"vue-i18n": {
|
||||
localeDir: "src/i18n/en.json",
|
||||
messageSyntaxVersion: "^11.0.0",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"@intlify/vue-i18n/no-missing-keys": "error",
|
||||
"@intlify/vue-i18n/no-unused-keys": ["error", {
|
||||
src: "./src",
|
||||
extensions: [".js", ".vue", ".ts"],
|
||||
ignores: ["/^languages\\./"],
|
||||
}],
|
||||
"@intlify/vue-i18n/no-raw-text": ["error", {
|
||||
ignoreNodes: ["i", "v-icon"],
|
||||
}],
|
||||
"@intlify/vue-i18n/no-missing-keys-in-other-locales": "warn",
|
||||
},
|
||||
},
|
||||
|
||||
// Shared globals + rule overrides
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.vue"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.browser,
|
||||
...globals.es2022,
|
||||
globalVars: "readonly",
|
||||
router: "readonly",
|
||||
$t: "readonly",
|
||||
next: "readonly",
|
||||
downloadFiles: "readonly",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-empty-object-type": "warn",
|
||||
"@typescript-eslint/ban-ts-comment": "warn",
|
||||
"@typescript-eslint/no-unused-vars": ["error", {
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
caughtErrors: "none",
|
||||
}],
|
||||
"eqeqeq": ["warn", "always"],
|
||||
"no-var": "error",
|
||||
"prefer-const": "warn",
|
||||
"no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true }],
|
||||
"prefer-template": "warn",
|
||||
"@typescript-eslint/consistent-type-definitions": "warn",
|
||||
"@typescript-eslint/prefer-optional-chain": "warn",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-unnecessary-condition": "off", // this one is useful, but is pretty noisy and found lot of false positives
|
||||
"@typescript-eslint/no-dynamic-delete": "warn",
|
||||
"@typescript-eslint/no-misused-promises": "error",
|
||||
"prefer-object-has-own": "error",
|
||||
"no-prototype-builtins": "error",
|
||||
"no-implied-eval": "error",
|
||||
"no-restricted-globals": [
|
||||
"error",
|
||||
{ name: "isNaN", message: "Use Number.isNaN instead." },
|
||||
{ name: "isFinite", message: "Use Number.isFinite instead." }
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
files: ["**/*.ts", "**/*.js"],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
extraFileExtensions: ['.vue'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Vue files
|
||||
{
|
||||
files: ["**/*.vue"],
|
||||
languageOptions: {
|
||||
parser: vueParser,
|
||||
parserOptions: {
|
||||
parser: tseslint.parser,
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
projectService: true,
|
||||
extraFileExtensions: ['.vue'],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"vue/multi-word-component-names": "off",
|
||||
"vue/no-mutating-props": ["error", { shallowOnly: true }],
|
||||
//"vue/order-in-components": "warn",
|
||||
"vue/require-v-for-key": "error",
|
||||
"vue/no-reserved-component-names": "off",
|
||||
"vue/no-unused-components": "warn",
|
||||
//"vue/no-v-html": "warn",
|
||||
"vue/no-v-text-v-html-on-component": "warn",
|
||||
},
|
||||
},
|
||||
// Relax the rules a bit for tests files
|
||||
{
|
||||
files: ["tests/**/*.ts", "**/*.spec.ts", "**/*.test.ts"],
|
||||
rules: {
|
||||
"preserve-caught-error": "off",
|
||||
"no-empty-pattern": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none" }],
|
||||
"no-unused-expressions": "off",
|
||||
"security/detect-non-literal-regexp": "off",
|
||||
},
|
||||
},
|
||||
);
|
||||
Generated
+1285
-1378
File diff suppressed because it is too large.
Load diff
+13
-10
@@ -18,7 +18,7 @@
|
||||
"i18n:check": "node ./scripts/sync-translations.js --check",
|
||||
"i18n:enforce-order": "node scripts/sync-translations.js --enforce-order",
|
||||
"i18n:cleanup": "node scripts/sync-translations.js --cleanup",
|
||||
"format": "prettier --write .",
|
||||
"format": "biome format --write .",
|
||||
"test": "vitest run "
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -38,8 +38,7 @@
|
||||
"srt-support-for-html5-videos": "^2.6.11",
|
||||
"three": "^0.182.0",
|
||||
"vue": "^3.4.21",
|
||||
"vue-i18n": "^9.10.2",
|
||||
"vue-lazyload": "^3.0.0",
|
||||
"vue-i18n": "^11.4.4",
|
||||
"vue-router": "^4.3.0"
|
||||
},
|
||||
"overrides": {
|
||||
@@ -47,23 +46,27 @@
|
||||
"@xmldom/xmldom": "^0.8.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@intlify/eslint-plugin-vue-i18n": "^3.2.0",
|
||||
"@intlify/unplugin-vue-i18n": "^4.0.0",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@intlify/eslint-plugin-vue-i18n": "^4.4.0",
|
||||
"@intlify/unplugin-vue-i18n": "^11.2.3",
|
||||
"@playwright/test": "^1.54.1",
|
||||
"@types/eslint-plugin-security": "^3.0.1",
|
||||
"@types/node": "^24.1.0",
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"@vue/eslint-config-typescript": "^13.0.0",
|
||||
"deepl-node": "^1.16.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-vue": "^9.24.0",
|
||||
"eslint": "^10.4.0",
|
||||
"eslint-plugin-security": "^4.0.0",
|
||||
"eslint-plugin-vue": "^10.9.1",
|
||||
"fs-extra": "^11.3.0",
|
||||
"globals": "^17.6.0",
|
||||
"jsdom": "^25.0.1",
|
||||
"typescript": "^6.0.0",
|
||||
"typescript-eslint": "^8.59.4",
|
||||
"vite": "^6.2.0",
|
||||
"vite-plugin-checker": "^0.10.3",
|
||||
"vite-plugin-compression2": "^1.0.0",
|
||||
"vitest": "^3.0.7",
|
||||
"vitest": "^4.1.8",
|
||||
"vue-eslint-parser": "^10.4.0",
|
||||
"vue-tsc": "^2.0.7"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
server:
|
||||
minSearchLength: 3 # minimum length of search query to begin searching (default: 3)
|
||||
disableUpdateCheck: false # disables backend update check service
|
||||
numImageProcessors: 4 # number of concurrent image processing jobs used to create previews, default is number of cpu cores available.
|
||||
socket: "" # socket to listen on
|
||||
numImageProcessors: 4 # number of concurrent image processing jobs used to create previews, default is 4.
|
||||
socket: "" # socket to listen on - eg. /var/run/filebrowser.sock
|
||||
tlsKey: "" # path to TLS key
|
||||
tlsCert: "" # path to TLS cert
|
||||
disablePreviews: false # disable all previews thumbnails, simple icons will be used
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<meta name="theme-color" content="{{ .htmlVars.color }}">
|
||||
|
||||
<!-- Add to home screen for Safari on iOS/iPadOS -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-title" content="assets">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ .htmlVars.appIcon }}">
|
||||
@@ -51,6 +52,12 @@
|
||||
<!-- Injected variables come from backend server -->
|
||||
<script>
|
||||
window.globalVars = {{ .globalVars }};
|
||||
window.__pwaDeferredPrompt = null;
|
||||
window.addEventListener("beforeinstallprompt", function (event) {
|
||||
event.preventDefault();
|
||||
window.__pwaDeferredPrompt = event;
|
||||
window.dispatchEvent(new Event("pwa-install-available"));
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable security/detect-object-injection */
|
||||
// scripts/sync-translations.js
|
||||
import fs from 'fs-extra';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import * as glob from 'glob';
|
||||
import * as deepl from 'deepl-node';
|
||||
import fs from 'fs-extra';
|
||||
import * as glob from 'glob';
|
||||
|
||||
// Parse command line arguments
|
||||
const args = process.argv.slice(2);
|
||||
@@ -76,7 +77,7 @@ async function translateText(text, targetLanguage, keyPath = '') {
|
||||
try {
|
||||
console.log(`Translating "${text}" from '${masterLanguageCode}' to '${targetLanguage}'...`);
|
||||
|
||||
let deeplTargetLang = deeplLangMap[targetLanguage.toLowerCase()] || targetLanguage.toUpperCase();
|
||||
const deeplTargetLang = deeplLangMap[targetLanguage.toLowerCase()] || targetLanguage.toUpperCase();
|
||||
|
||||
const result = await translator.translateText(textToTranslate, masterLanguageCode, deeplTargetLang, options);
|
||||
|
||||
@@ -104,8 +105,8 @@ function reorderObject(obj, masterObj) {
|
||||
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) return obj;
|
||||
const newObj = {};
|
||||
for (const key in masterObj) {
|
||||
if (Object.prototype.hasOwnProperty.call(masterObj, key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
if (Object.hasOwn(masterObj, key)) {
|
||||
if (Object.hasOwn(obj, key)) {
|
||||
newObj[key] = reorderObject(obj[key], masterObj[key]);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +121,7 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
|
||||
// First pass: Add/update keys from master to target
|
||||
for (const key in masterObj) {
|
||||
if (Object.prototype.hasOwnProperty.call(masterObj, key)) {
|
||||
if (Object.hasOwn(masterObj, key)) {
|
||||
const currentPathPartsNext = [...currentPathParts, key];
|
||||
const currentKeyPath = currentPathPartsNext.join('.');
|
||||
|
||||
@@ -153,7 +154,7 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
if (targetObj[key] && typeof targetObj[key] === 'object') {
|
||||
const result = await processKeys( masterValue, targetObj[key], targetLangCode, currentPathPartsNext,
|
||||
doEnforceOrder, doCleanupOnly);
|
||||
if (result == "UNSUPPORTED") {
|
||||
if (result === "UNSUPPORTED") {
|
||||
console.log(`Skipping translation for "${targetLangCode}" due to unsupported structure.`);
|
||||
return "UNSUPPORTED";
|
||||
}
|
||||
@@ -168,7 +169,7 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
// Only handle non‑object values
|
||||
if (typeof masterValue === 'string') {
|
||||
const existingTargetValue = targetObj[key];
|
||||
const isMissing = !Object.prototype.hasOwnProperty.call(targetObj, key) || existingTargetValue === '' || existingTargetValue === null;
|
||||
const isMissing = !Object.hasOwn(targetObj, key) || existingTargetValue === '' || existingTargetValue === null;
|
||||
|
||||
if (isMissing) {
|
||||
if (checkOnly) {
|
||||
@@ -180,7 +181,7 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
} else {
|
||||
// Sync translation
|
||||
const result = await translateText(masterValue, targetLangCode, currentKeyPath);
|
||||
if (result == "") {
|
||||
if (result === "") {
|
||||
return "UNSUPPORTED";
|
||||
}
|
||||
targetObj[key] = result;
|
||||
@@ -188,7 +189,7 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!Object.prototype.hasOwnProperty.call(targetObj, key)) {
|
||||
if (!Object.hasOwn(targetObj, key)) {
|
||||
if (checkOnly) {
|
||||
console.log(`Would copy key "${currentKeyPath}" (non-string) from English to ${targetLangCode}.json`);
|
||||
meaningfulChanges++; // Copying non-string values is meaningful
|
||||
@@ -206,8 +207,8 @@ async function processKeys(masterObj, targetObj, targetLangCode, currentPathPart
|
||||
// Second pass: Remove obsolete keys that exist in target but not in master
|
||||
const keysToRemove = [];
|
||||
for (const key in targetObj) {
|
||||
if (Object.prototype.hasOwnProperty.call(targetObj, key)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(masterObj, key)) {
|
||||
if (Object.hasOwn(targetObj, key)) {
|
||||
if (!Object.hasOwn(masterObj, key)) {
|
||||
keysToRemove.push(key);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +260,7 @@ async function syncAllTranslations() {
|
||||
const targetLangCode = path.basename(targetFile, '.json');
|
||||
let targetContent = {};
|
||||
let originalTargetContent = null;
|
||||
let fileExisted = await fs.pathExists(targetFile);
|
||||
const fileExisted = await fs.pathExists(targetFile);
|
||||
|
||||
if (fileExisted) {
|
||||
try {
|
||||
@@ -349,4 +350,4 @@ syncAllTranslations()
|
||||
.catch(error => {
|
||||
console.error("\n❌ An error occurred during translation synchronization:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@
|
||||
<script>
|
||||
import { onMounted } from "vue";
|
||||
import { mutations } from "@/store"; // Import your store's mutations
|
||||
|
||||
mutations.setLoading("main-app", true);
|
||||
export default {
|
||||
name: "app",
|
||||
@@ -21,9 +22,3 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Always load styles.css */
|
||||
@import "./css/styles.css";
|
||||
@import "./css/dark.css";
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fetchJSON } from './utils'
|
||||
import { getApiPath } from '@/utils/url.js'
|
||||
import { fetchJSON } from './utils'
|
||||
|
||||
/**
|
||||
* @param {string} source
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchURL } from "./utils";
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { notify } from "@/notify";
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { fetchURL } from "./utils";
|
||||
|
||||
/**
|
||||
* Create an archive on the server (server-side only).
|
||||
@@ -15,7 +15,7 @@ import { notify } from "@/notify";
|
||||
*/
|
||||
export async function createArchive(opts) {
|
||||
const { fromSource, toSource, paths, destination, format, compression, deleteAfter } = opts;
|
||||
if (!fromSource || !paths?.length || !destination) {
|
||||
if (!fromSource || !Array.isArray(paths) || paths.length === 0 || !destination) {
|
||||
throw new Error("fromSource, paths, and destination are required");
|
||||
}
|
||||
const body = {
|
||||
|
||||
+38
-35
@@ -1,6 +1,6 @@
|
||||
import { fetchURL, fetchJSON } from '@/api/utils'
|
||||
import { getApiPath } from '@/utils/url.js'
|
||||
import { fetchJSON, fetchURL } from '@/api/utils'
|
||||
import { notify } from '@/notify'
|
||||
import { getApiPath } from '@/utils/url.js'
|
||||
|
||||
// POST /api/auth/login
|
||||
export async function login(username, password, recaptcha, otp) {
|
||||
@@ -14,29 +14,33 @@ export async function login(username, password, recaptcha, otp) {
|
||||
password = ''
|
||||
}
|
||||
|
||||
const params = { username, recaptcha };
|
||||
let apiPath = getApiPath('auth/login', params);
|
||||
const res = await fetch(apiPath, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'X-Password': encodeURIComponent(password),
|
||||
'X-Secret': otp,
|
||||
}
|
||||
});
|
||||
|
||||
const bodyText = await res.text();
|
||||
let body;
|
||||
|
||||
try {
|
||||
body = JSON.parse(bodyText);
|
||||
} catch {
|
||||
body = { message: bodyText };
|
||||
}
|
||||
const params = { username, recaptcha };
|
||||
const apiPath = getApiPath('auth/login', params);
|
||||
const res = await fetch(apiPath, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'X-Password': encodeURIComponent(password),
|
||||
'X-Secret': otp,
|
||||
}
|
||||
});
|
||||
|
||||
if (res.status != 200) {
|
||||
const msg = body.message || 'Forbidden';
|
||||
throw new Error(msg);
|
||||
const bodyText = await res.text();
|
||||
let body;
|
||||
|
||||
try {
|
||||
body = JSON.parse(bodyText);
|
||||
} catch {
|
||||
body = { message: bodyText };
|
||||
}
|
||||
|
||||
if (res.status !== 200) {
|
||||
const msg = body.message || 'Forbidden';
|
||||
throw new Error(msg);
|
||||
}
|
||||
} catch (err) {
|
||||
throw err instanceof Error ? err : new Error(String(err));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +58,7 @@ export async function logout() {
|
||||
// POST /api/auth/signup
|
||||
export async function signup(username, password, otp) {
|
||||
const params = { username, password, otp }
|
||||
let apiPath = getApiPath('auth/signup', params)
|
||||
const apiPath = getApiPath('auth/signup', params)
|
||||
const res = await fetch(apiPath, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -69,7 +73,7 @@ export async function signup(username, password, otp) {
|
||||
if (errorData.message) {
|
||||
errorMessage = errorData.message
|
||||
}
|
||||
} catch (parseError) {
|
||||
} catch (_parseError) {
|
||||
// If parsing fails, keep the status code as error message
|
||||
}
|
||||
throw new Error(errorMessage)
|
||||
@@ -80,7 +84,7 @@ export async function signup(username, password, otp) {
|
||||
export async function generateOTP(username, password) {
|
||||
const params = { username }
|
||||
try {
|
||||
let apiPath = getApiPath('auth/otp/generate', params)
|
||||
const apiPath = getApiPath('auth/otp/generate', params)
|
||||
const res = await fetch(apiPath, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
@@ -104,7 +108,7 @@ export async function generateOTP(username, password) {
|
||||
export async function verifyOTP(username, password, otp) {
|
||||
const params = { username }
|
||||
try {
|
||||
let apiPath = getApiPath('auth/otp/verify', params)
|
||||
const apiPath = getApiPath('auth/otp/verify', params)
|
||||
const res = await fetch(apiPath, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
@@ -113,7 +117,7 @@ export async function verifyOTP(username, password, otp) {
|
||||
'X-Secret': otp,
|
||||
}
|
||||
})
|
||||
if (res.status != 200) {
|
||||
if (res.status !== 200) {
|
||||
let msg = 'Failed to verify OTP'
|
||||
try {
|
||||
const errBody = await res.json()
|
||||
@@ -171,10 +175,10 @@ export async function createApiKey(params) {
|
||||
}
|
||||
|
||||
// DELETE /api/auth/token
|
||||
export function deleteApiKey(params) {
|
||||
export async function deleteApiKey(params) {
|
||||
try {
|
||||
const apiPath = getApiPath('auth/token', params)
|
||||
fetchURL(apiPath, {
|
||||
await fetchURL(apiPath, {
|
||||
method: 'DELETE'
|
||||
})
|
||||
} catch (err) {
|
||||
@@ -186,7 +190,9 @@ export function deleteApiKey(params) {
|
||||
function arrayBufferToBase64(buffer) {
|
||||
const bytes = new Uint8Array(buffer)
|
||||
let binary = ''
|
||||
bytes.forEach(b => binary += String.fromCharCode(b))
|
||||
bytes.forEach(b => {
|
||||
binary += String.fromCharCode(b);
|
||||
})
|
||||
return btoa(binary).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
|
||||
}
|
||||
|
||||
@@ -195,10 +201,7 @@ function base64ToArrayBuffer(base64url) {
|
||||
let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/')
|
||||
while (base64.length % 4) base64 += '='
|
||||
const binary = atob(base64)
|
||||
const bytes = new Uint8Array(binary.length)
|
||||
for (let i = 0; i < binary.length; i++) {
|
||||
bytes[i] = binary.charCodeAt(i)
|
||||
}
|
||||
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0))
|
||||
return bytes.buffer
|
||||
}
|
||||
|
||||
|
||||
+15
-16
@@ -10,25 +10,24 @@
|
||||
// - /api/media/ -> media.js
|
||||
// - /public/api/* -> public functions in respective files (e.g., resourcesApi.fetchFilesPublic)
|
||||
|
||||
import * as authApi from "./auth";
|
||||
import * as usersApi from "./users";
|
||||
import * as resourcesApi from "./resources";
|
||||
import * as accessApi from "./access";
|
||||
import * as shareApi from "./share";
|
||||
import * as settingsApi from "./settings";
|
||||
import * as toolsApi from "./tools";
|
||||
import * as officeApi from "./office";
|
||||
import * as authApi from "./auth";
|
||||
import * as mediaApi from "./media";
|
||||
import * as officeApi from "./office";
|
||||
import * as resourcesApi from "./resources";
|
||||
import * as settingsApi from "./settings";
|
||||
import * as shareApi from "./share";
|
||||
import * as toolsApi from "./tools";
|
||||
import * as usersApi from "./users";
|
||||
|
||||
export {
|
||||
authApi,
|
||||
usersApi,
|
||||
resourcesApi,
|
||||
export {
|
||||
accessApi,
|
||||
shareApi,
|
||||
settingsApi,
|
||||
toolsApi,
|
||||
authApi,
|
||||
mediaApi,
|
||||
officeApi,
|
||||
mediaApi
|
||||
resourcesApi,
|
||||
settingsApi,
|
||||
shareApi,
|
||||
toolsApi,
|
||||
usersApi,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { fetchURL, adjustedData } from "./utils";
|
||||
import { notify } from "@/notify";
|
||||
import { getApiPath, getPublicApiPath } from "@/utils/url.js";
|
||||
import { state } from "@/store";
|
||||
import { getApiPath, getPublicApiPath } from "@/utils/url.js";
|
||||
import { adjustedData, fetchURL } from "./utils";
|
||||
|
||||
// GET /api/media/subtitles
|
||||
export async function getSubtitleContent(source, path, subtitleName, embedded = false) {
|
||||
@@ -45,8 +45,7 @@ export async function getLyricsPublic(path, hash, password = "") {
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = new Error(response.statusText);
|
||||
let data = null;
|
||||
data = await response.json();
|
||||
const data = await response.json();
|
||||
if (data?.message) {
|
||||
error.message = data.message;
|
||||
}
|
||||
@@ -90,7 +89,7 @@ export async function fetchDirectoryMediaMetadataPublic(path, hash, password = "
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// ignore
|
||||
}
|
||||
if (data?.message) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchURL } from './utils'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { notify } from '@/notify'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { fetchURL } from './utils'
|
||||
|
||||
// GET /api/office/config or /public/api/office/config
|
||||
export async function getConfig(req) {
|
||||
@@ -27,7 +27,7 @@ export async function getConfig(req) {
|
||||
}
|
||||
|
||||
// POST /api/office/callback or /public/api/office/callback
|
||||
export async function callback(params, hash = null) {
|
||||
export async function callback(params, hash) {
|
||||
try {
|
||||
let apiPath
|
||||
if (hash) {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { fetchURL, adjustedData } from './utils'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { state, mutations } from '@/store'
|
||||
import { notify } from '@/notify'
|
||||
import { mutations, state } from '@/store'
|
||||
import { globalVars } from '@/utils/constants'
|
||||
import { downloadManager } from '@/utils/downloadManager'
|
||||
import {
|
||||
notifyDownloadComplete,
|
||||
notifyDownloadError,
|
||||
} from '@/utils/appNotifications'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { adjustedData, fetchURL } from './utils'
|
||||
import { getObjectProperty } from '@/utils/object'
|
||||
|
||||
export { fetchPreviewImage } from '@/utils/previewRequests'
|
||||
|
||||
// Notify if errors occur
|
||||
export async function fetchFiles(source, path, content = false, metadata = false, skipExtendedAttrs = false) {
|
||||
@@ -51,14 +58,14 @@ export async function getItems(source, path, only = "") {
|
||||
* Registers a graceful pause for the active chunked upload at this path.
|
||||
* Call immediately before aborting the chunk XHR so the server keeps partial data.
|
||||
*/
|
||||
export async function signalUploadPause(source, path, shareHash = null) {
|
||||
export async function signalUploadPause(source, path, shareHash) {
|
||||
if (shareHash) {
|
||||
const apiPath = getPublicApiPath('resources/pause', {
|
||||
hash: shareHash,
|
||||
path: path,
|
||||
})
|
||||
const headers = {}
|
||||
const sharePassword = localStorage.getItem('sharepass:' + shareHash)
|
||||
const sharePassword = localStorage.getItem(`sharepass:${shareHash}`)
|
||||
if (sharePassword) {
|
||||
headers['X-SHARE-PASSWORD'] = sharePassword
|
||||
}
|
||||
@@ -78,7 +85,7 @@ async function resourceAction(source, path, method, content) {
|
||||
}
|
||||
try {
|
||||
const apiPath = getApiPath('resources', { path, source })
|
||||
let opts = { method }
|
||||
const opts = { method }
|
||||
if (content) {
|
||||
opts.body = content
|
||||
}
|
||||
@@ -90,7 +97,7 @@ async function resourceAction(source, path, method, content) {
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json()
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// ignore
|
||||
}
|
||||
if (data) {
|
||||
@@ -177,7 +184,7 @@ export async function download(format, files, shareHash = "") {
|
||||
if (shareHash) {
|
||||
filePaths = files.map((file) => file.path)
|
||||
} else {
|
||||
for (let file of files) {
|
||||
for (const file of files) {
|
||||
if (!file.source) {
|
||||
throw new Error('File source is required for downloads')
|
||||
}
|
||||
@@ -264,11 +271,17 @@ async function resolveDownloadContentLength(url) {
|
||||
headers: { Range: 'bytes=0-0' },
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
const cancelBody = () => {
|
||||
if (res.body && typeof res.body.cancel === 'function') {
|
||||
res.body.cancel().catch(() => {})
|
||||
}
|
||||
}
|
||||
try {
|
||||
token = res.headers.get('X-Archive-Token') || token
|
||||
if (res.status === 206) {
|
||||
const total = totalFromContentRange(res.headers.get('Content-Range'))
|
||||
if (total > 0) {
|
||||
cancelBody()
|
||||
return { size: total, token }
|
||||
}
|
||||
}
|
||||
@@ -277,20 +290,17 @@ async function resolveDownloadContentLength(url) {
|
||||
if (cl) {
|
||||
const n = parseInt(cl, 10)
|
||||
if (Number.isFinite(n) && n > 0) {
|
||||
cancelBody()
|
||||
return { size: n, token }
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (res.body && typeof res.body.cancel === 'function') {
|
||||
try {
|
||||
await res.body.cancel()
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
cancelBody()
|
||||
return { size: 0, token }
|
||||
} catch (e) {
|
||||
cancelBody()
|
||||
throw e
|
||||
}
|
||||
return { size: 0, token: null }
|
||||
}
|
||||
|
||||
function archiveDisplayFileName(format, files) {
|
||||
@@ -299,20 +309,20 @@ function archiveDisplayFileName(format, files) {
|
||||
if (files.length === 1 && first.isDir) {
|
||||
const base =
|
||||
first.name ||
|
||||
(first.path && first.path.split('/').filter(Boolean).pop()) ||
|
||||
(first.path?.split('/').filter(Boolean).pop()) ||
|
||||
'download'
|
||||
return base + ext
|
||||
return `${base}${ext}`
|
||||
}
|
||||
if (first && first.path) {
|
||||
if (first?.path) {
|
||||
const parts = first.path.split('/').filter(Boolean)
|
||||
if (parts.length >= 2) {
|
||||
return parts[parts.length - 2] + ext
|
||||
return `${parts[parts.length - 2]}${ext}`
|
||||
}
|
||||
if (parts.length === 1) {
|
||||
return parts[0] + ext
|
||||
return `${parts[0]}${ext}`
|
||||
}
|
||||
}
|
||||
return 'download' + ext
|
||||
return `download${ext}`
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +347,7 @@ async function chunkedRangeDownloadToBlob(
|
||||
|
||||
while (offset < totalSize) {
|
||||
const download = downloadManager.findById(downloadId)
|
||||
if (download && download.status === 'cancelled') {
|
||||
if (download?.status === 'cancelled') {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -430,7 +440,7 @@ async function chunkedRangeDownloadToBlob(
|
||||
}
|
||||
} catch (readError) {
|
||||
const download = downloadManager.findById(downloadId)
|
||||
if (readError.name === 'AbortError' || (download && download.status === 'cancelled')) {
|
||||
if (readError.name === 'AbortError' || (download?.status === 'cancelled')) {
|
||||
downloadManager.setStatus(downloadId, 'cancelled')
|
||||
return null
|
||||
}
|
||||
@@ -492,7 +502,7 @@ async function downloadChunkedArchive(url, format, files, filePaths, source, sha
|
||||
|
||||
downloadManager.setStatus(downloadId, 'downloading')
|
||||
|
||||
const hasDownloadPrompt = state.prompts && state.prompts.some((h) => h.name === 'download')
|
||||
const hasDownloadPrompt = state.prompts.some((h) => h.name === 'download')
|
||||
if (!hasDownloadPrompt) {
|
||||
mutations.showPrompt({ name: 'download' })
|
||||
}
|
||||
@@ -525,6 +535,7 @@ async function downloadChunkedArchive(url, format, files, filePaths, source, sha
|
||||
|
||||
downloadManager.setStatus(downloadId, 'completed')
|
||||
downloadManager.updateProgress(downloadId, fileSize, fileSize)
|
||||
notifyDownloadComplete(fileName, fileSize)
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link)
|
||||
@@ -532,13 +543,14 @@ async function downloadChunkedArchive(url, format, files, filePaths, source, sha
|
||||
}, 100)
|
||||
} catch (error) {
|
||||
const download = downloadManager.findById(downloadId)
|
||||
if (error.name === 'AbortError' || (download && download.status === 'cancelled')) {
|
||||
if (error.name === 'AbortError' || (download?.status === 'cancelled')) {
|
||||
downloadManager.setStatus(downloadId, 'cancelled')
|
||||
return
|
||||
}
|
||||
const message =
|
||||
error instanceof Error ? error.message || 'Unknown error' : String(error)
|
||||
downloadManager.setError(downloadId, message)
|
||||
notifyDownloadError(fileName, message)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -580,7 +592,7 @@ async function downloadChunked(file, shareHash = "") {
|
||||
downloadManager.setStatus(downloadId, "downloading")
|
||||
|
||||
// Show download prompt if not already shown (it should already be shown by downloadFiles, but check to be safe)
|
||||
const hasDownloadPrompt = state.prompts && state.prompts.some(h => h.name === 'download');
|
||||
const hasDownloadPrompt = state.prompts.some(h => h.name === 'download');
|
||||
|
||||
if (!hasDownloadPrompt) {
|
||||
mutations.showPrompt({ name: 'download' })
|
||||
@@ -615,6 +627,7 @@ async function downloadChunked(file, shareHash = "") {
|
||||
const dlDone = downloadManager.findById(downloadId)
|
||||
const finalSize = dlDone?.size ?? fileSize
|
||||
downloadManager.updateProgress(downloadId, finalSize, finalSize)
|
||||
notifyDownloadComplete(fileName, finalSize)
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link)
|
||||
@@ -623,7 +636,7 @@ async function downloadChunked(file, shareHash = "") {
|
||||
} catch (error) {
|
||||
// Check if download was cancelled by user
|
||||
const download = downloadManager.findById(downloadId);
|
||||
if (error.name === 'AbortError' || (download && download.status === "cancelled")) {
|
||||
if (error.name === 'AbortError' || (download?.status === "cancelled")) {
|
||||
downloadManager.setStatus(downloadId, "cancelled")
|
||||
// Don't throw error or show notification for user-initiated cancellation
|
||||
return;
|
||||
@@ -631,6 +644,7 @@ async function downloadChunked(file, shareHash = "") {
|
||||
const message =
|
||||
error instanceof Error ? error.message || "Unknown error" : String(error)
|
||||
downloadManager.setError(downloadId, message)
|
||||
notifyDownloadError(fileName, message)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -658,9 +672,9 @@ export function post(
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("POST", apiPath, true);
|
||||
|
||||
for (const header in headers) {
|
||||
request.setRequestHeader(header, headers[header]);
|
||||
}
|
||||
Object.entries(headers).forEach(([header, value]) => {
|
||||
request.setRequestHeader(header, value);
|
||||
});
|
||||
|
||||
if (typeof onupload === "function") {
|
||||
request.upload.onprogress = (event) => {
|
||||
@@ -686,7 +700,7 @@ export function post(
|
||||
try {
|
||||
const errorData = JSON.parse(request.responseText);
|
||||
errorMessage = errorData.message || errorMessage;
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
errorMessage = request.responseText || errorMessage;
|
||||
}
|
||||
const error = new Error(errorMessage);
|
||||
@@ -803,7 +817,7 @@ export async function checksum(source, path, algo) {
|
||||
const apiPath = getApiPath('resources', params)
|
||||
const res = await fetchURL(apiPath)
|
||||
const data = await res.json()
|
||||
return data.checksums[algo]
|
||||
return getObjectProperty(data.checksums, algo)
|
||||
} catch (err) {
|
||||
notify.showError(err.message || 'Error fetching checksum')
|
||||
throw err
|
||||
@@ -831,6 +845,10 @@ export function getDownloadURL(source, path, inline, useExternal) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a preview API URL. Use fetchPreviewImage(url, signal) to load it;
|
||||
* pass an AbortSignal so the caller can cancel on navigation or unmount.
|
||||
*/
|
||||
export function getPreviewURL(source, path, modified) {
|
||||
if (!source || source === undefined || source === null) {
|
||||
throw new Error('no source provided')
|
||||
@@ -853,7 +871,7 @@ export function getPreviewURL(source, path, modified) {
|
||||
// POST /api/resources/archive - Create an archive
|
||||
export async function createArchive(opts) {
|
||||
const { fromSource, toSource, paths, destination, format, compression, deleteAfter } = opts;
|
||||
if (!fromSource || !paths?.length || !destination) {
|
||||
if (!fromSource || !Array.isArray(paths) || paths.length === 0 || !destination) {
|
||||
throw new Error("fromSource, paths, and destination are required");
|
||||
}
|
||||
const body = {
|
||||
@@ -940,7 +958,7 @@ export async function fetchFilesPublic(path, hash, password = "", content = fals
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json()
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// ignore
|
||||
}
|
||||
if (data) {
|
||||
@@ -949,7 +967,7 @@ export async function fetchFilesPublic(path, hash, password = "", content = fals
|
||||
(/** @type {any} */ (error)).status = response.status;
|
||||
throw error;
|
||||
}
|
||||
let data = await response.json()
|
||||
const data = await response.json()
|
||||
const adjusted = adjustedData(data);
|
||||
return adjusted
|
||||
}
|
||||
@@ -1027,7 +1045,7 @@ export function postPublic(
|
||||
if (!hash || hash === undefined || hash === null) {
|
||||
throw new Error('no hash provided')
|
||||
}
|
||||
let sharePassword = localStorage.getItem("sharepass:" + hash);
|
||||
const sharePassword = localStorage.getItem(`sharepass:${hash}`);
|
||||
if (sharePassword) {
|
||||
headers["X-SHARE-PASSWORD"] = sharePassword;
|
||||
}
|
||||
@@ -1042,9 +1060,10 @@ export function postPublic(
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("POST", apiPath, true);
|
||||
|
||||
for (const header in headers) {
|
||||
request.setRequestHeader(header, headers[header]);
|
||||
}
|
||||
Object.entries(headers).forEach(([header, value]) => {
|
||||
request.setRequestHeader(header, value);
|
||||
});
|
||||
|
||||
if (typeof onupload === "function") {
|
||||
request.upload.onprogress = (event) => {
|
||||
if (event.lengthComputable) {
|
||||
@@ -1069,7 +1088,7 @@ export function postPublic(
|
||||
try {
|
||||
const errorData = JSON.parse(request.responseText);
|
||||
errorMessage = errorData.message || errorMessage;
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
errorMessage = request.responseText || errorMessage;
|
||||
}
|
||||
|
||||
@@ -1114,8 +1133,8 @@ export function postPublic(
|
||||
|
||||
async function resourceActionPublic(hash, path, method, content, token = "") {
|
||||
try {
|
||||
let headers = {};
|
||||
let sharePassword = localStorage.getItem("sharepass:" + hash);
|
||||
const headers = {};
|
||||
const sharePassword = localStorage.getItem(`sharepass:${hash}`);
|
||||
if (sharePassword) {
|
||||
headers["X-SHARE-PASSWORD"] = sharePassword;
|
||||
}
|
||||
@@ -1130,7 +1149,7 @@ async function resourceActionPublic(hash, path, method, content, token = "") {
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json()
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// ignore
|
||||
}
|
||||
if (data) {
|
||||
@@ -1155,7 +1174,7 @@ export async function bulkDeletePublic(items) {
|
||||
throw new Error('items array is required and must not be empty')
|
||||
}
|
||||
|
||||
const hash = state.shareInfo?.hash;
|
||||
const hash = state.shareInfo.hash;
|
||||
if (!hash) {
|
||||
throw new Error('share hash is required')
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchURL } from "./utils";
|
||||
import { notify } from "@/notify"; // Import notify for error handling
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { fetchURL } from "./utils";
|
||||
|
||||
export default async function search(base, sources, query, largest = false, extraParams = {}) {
|
||||
try {
|
||||
@@ -34,7 +34,7 @@ export default async function search(base, sources, query, largest = false, extr
|
||||
|
||||
const apiPath = getApiPath("tools/search", params);
|
||||
const res = await fetchURL(apiPath);
|
||||
let data = await res.json();
|
||||
const data = await res.json();
|
||||
|
||||
return data
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { fetchURL, fetchJSON } from "./utils";
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { notify } from "@/notify";
|
||||
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { fetchJSON, fetchURL } from "./utils";
|
||||
|
||||
export function get(property="") {
|
||||
const path = getApiPath("settings", { property });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchURL, fetchJSON, adjustedData } from "./utils";
|
||||
import { notify } from "@/notify";
|
||||
import { getApiPath, getPublicApiPath } from "@/utils/url.js";
|
||||
import { adjustedData, fetchJSON, fetchURL } from "./utils";
|
||||
|
||||
|
||||
// ============================================================================
|
||||
@@ -28,7 +28,7 @@ export async function get(path, source) {
|
||||
try {
|
||||
const params = { path, source };
|
||||
const apiPath = getApiPath("share", params);
|
||||
let data = await fetchJSON(apiPath);
|
||||
const data = await fetchJSON(apiPath);
|
||||
return adjustedData(data);
|
||||
} catch (/** @type {any} */ err) {
|
||||
notify.showError(err.message || "Error fetching data");
|
||||
@@ -64,7 +64,7 @@ export async function create(bodyObj = {}) {
|
||||
const apiPath = getApiPath("share");
|
||||
return await fetchJSON(apiPath, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(bodyObj || {}),
|
||||
body: JSON.stringify(bodyObj),
|
||||
});
|
||||
} catch (/** @type {any} */ err) {
|
||||
notify.showError(err.message || "Error creating share");
|
||||
@@ -124,3 +124,14 @@ export async function getShareInfoPublic(hash) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// PATCH /public/api/share/pinnedItems (add by default; ?action=remove to unpin)
|
||||
export async function patchPinnedItem({ hash, path, name, action = 'add' }) {
|
||||
const params = { hash, action }
|
||||
const apiPath = getPublicApiPath('share/pinnedItems', params)
|
||||
await fetchURL(apiPath, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ path, name }),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchURL } from "./utils";
|
||||
import { notify } from "@/notify";
|
||||
import { getApiPath } from "@/utils/url.js";
|
||||
import { fetchURL } from "./utils";
|
||||
|
||||
// GET /api/tools/search
|
||||
// extraParams: optional { olderThan, newerThan, useWildcard, terms, termJoin, perSourceScopes }
|
||||
@@ -75,7 +75,7 @@ export async function search(base, sources, query, largest = false, extraParams
|
||||
|
||||
const apiPath = getApiPath("tools/search", params);
|
||||
const res = await fetchURL(apiPath);
|
||||
let data = await res.json();
|
||||
const data = await res.json();
|
||||
|
||||
return data;
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fetchURL, fetchJSON } from '@/api/utils'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { getObjectProperty, setObjectProperty } from '@/utils/object'
|
||||
import { notify } from '@/notify'
|
||||
import { state } from '@/store/state.js'
|
||||
import { mutations } from '@/store/mutations.js'
|
||||
@@ -19,7 +20,7 @@ export async function getAllUsers() {
|
||||
// GET /api/users or /public/api/users (get single user)
|
||||
export async function get(id) {
|
||||
try {
|
||||
let apiPath = getPublicApiPath('users', { id: id })
|
||||
const apiPath = getPublicApiPath('users', { id: id })
|
||||
return await fetchJSON(apiPath)
|
||||
} catch (err) {
|
||||
notify.showError(err.message || `Failed to fetch user with ID: ${id}`)
|
||||
@@ -43,8 +44,7 @@ export async function create(user, options = {}) {
|
||||
state.user?.loginMethod === 'password' &&
|
||||
options.skipActorPasswordConfirm !== true &&
|
||||
mergedHeaders['X-Password'] === undefined &&
|
||||
err &&
|
||||
err.status === 401 &&
|
||||
err?.status === 401 &&
|
||||
typeof err.message === 'string' &&
|
||||
err.message.includes('X-Password')
|
||||
|
||||
@@ -108,8 +108,9 @@ export async function update(user, which = ['all'], options = {}) {
|
||||
if (which.length !== 1 || which[0] !== 'all') {
|
||||
userData = {}
|
||||
which.forEach(key => {
|
||||
if (key in user) {
|
||||
userData[key] = user[key]
|
||||
const value = getObjectProperty(user, key)
|
||||
if (value !== undefined) {
|
||||
userData = setObjectProperty(userData, key, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -124,8 +125,7 @@ export async function update(user, which = ['all'], options = {}) {
|
||||
state.user?.loginMethod === 'password' &&
|
||||
options.skipActorPasswordConfirm !== true &&
|
||||
mergedHeaders['X-Password'] === undefined &&
|
||||
err &&
|
||||
err.status === 401 &&
|
||||
err?.status === 401 &&
|
||||
typeof err.message === 'string' &&
|
||||
err.message.includes('X-Password')
|
||||
|
||||
@@ -168,6 +168,16 @@ export async function update(user, which = ['all'], options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
// PATCH /api/users/pinnedItems (add by default; ?action=remove to unpin)
|
||||
export async function patchPinnedItem({ source, path, name, action = 'add' }) {
|
||||
const params = { action }
|
||||
const apiPath = getApiPath('users/pinnedItems', params)
|
||||
await fetchURL(apiPath, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ source, path, name }),
|
||||
})
|
||||
}
|
||||
|
||||
// DELETE /api/users (remove user)
|
||||
// Password-login: tries without X-Password first; on 401 requiring X-Password, opens the prompt and retries.
|
||||
// options.skipActorPasswordConfirm / pre-set X-Password skip that flow.
|
||||
@@ -180,8 +190,7 @@ export async function remove(id, options = {}) {
|
||||
state.user?.loginMethod === 'password' &&
|
||||
options.skipActorPasswordConfirm !== true &&
|
||||
mergedHeaders['X-Password'] === undefined &&
|
||||
err &&
|
||||
err.status === 401 &&
|
||||
err?.status === 401 &&
|
||||
typeof err.message === 'string' &&
|
||||
err.message.includes('X-Password')
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import i18n from "@/i18n";
|
||||
import { state } from "@/store";
|
||||
import { renew } from "@/utils/auth";
|
||||
import i18n from "@/i18n";
|
||||
|
||||
export async function fetchURL(url, opts, auth = true) {
|
||||
opts = opts || {};
|
||||
opts.headers = opts.headers || {};
|
||||
|
||||
let { headers, ...rest } = opts;
|
||||
const { headers, ...rest } = opts;
|
||||
|
||||
let res;
|
||||
try {
|
||||
@@ -19,8 +19,8 @@ export async function fetchURL(url, opts, auth = true) {
|
||||
...rest,
|
||||
});
|
||||
} catch (e) {
|
||||
let message = e;
|
||||
if (e == "TypeError: Failed to fetch") {
|
||||
let message = e.message;
|
||||
if (e instanceof TypeError && e.message === "Failed to fetch") {
|
||||
message = i18n.global.t("errors.failedToConnectToServer");
|
||||
}
|
||||
const error = new Error(message);
|
||||
@@ -33,7 +33,7 @@ export async function fetchURL(url, opts, auth = true) {
|
||||
}
|
||||
|
||||
if (res.status < 200 || res.status > 299) {
|
||||
let error = new Error(await res.text());
|
||||
const error = new Error(await res.text());
|
||||
error.status = res.status;
|
||||
throw error;
|
||||
}
|
||||
@@ -52,6 +52,7 @@ export async function fetchJSON(url, opts) {
|
||||
|
||||
export function adjustedData(data) {
|
||||
if (data.type === "directory") {
|
||||
const pinnedNames = new Set(data.pinnedItems || []);
|
||||
// Combine folders and files into items
|
||||
data.items = [...(data.folders || []), ...(data.files || [])];
|
||||
data.items = data.items.map((item) => {
|
||||
@@ -59,7 +60,8 @@ export function adjustedData(data) {
|
||||
if (item.isShared === undefined) {
|
||||
item.isShared = false;
|
||||
}
|
||||
if (data.path == "/") {
|
||||
item.pinned = pinnedNames.has(item.name);
|
||||
if (data.path === "/") {
|
||||
if (item.type === "directory") {
|
||||
item.path = `/${item.name}/`
|
||||
} else {
|
||||
@@ -74,6 +76,7 @@ export function adjustedData(data) {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
delete data.pinnedItems;
|
||||
}
|
||||
if (data.files) {
|
||||
data.files = []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('@/utils/constants', () => {
|
||||
return {
|
||||
@@ -54,10 +54,10 @@ describe('adjustedData', () => {
|
||||
folders: [],
|
||||
files: [],
|
||||
items: [
|
||||
{ isShared: false, name: "folder1", path: "/root/folder1/", source: undefined, type: "directory" },
|
||||
{ isShared: false, name: "folder2", path: "/root/folder2/", source: undefined, type: "directory" },
|
||||
{ isShared: false, name: "file1.txt", path: "/root/file1.txt", source: undefined, type: "file" },
|
||||
{ isShared: false, name: "file2.txt", path: "/root/file2.txt", source: undefined, type: "file" },
|
||||
{ isShared: false, name: "folder1", path: "/root/folder1/", source: undefined, type: "directory", pinned: false },
|
||||
{ isShared: false, name: "folder2", path: "/root/folder2/", source: undefined, type: "directory", pinned: false },
|
||||
{ isShared: false, name: "file1.txt", path: "/root/file1.txt", source: undefined, type: "file", pinned: false },
|
||||
{ isShared: false, name: "file2.txt", path: "/root/file2.txt", source: undefined, type: "file", pinned: false },
|
||||
],
|
||||
path: "/root/",
|
||||
};
|
||||
@@ -105,5 +105,27 @@ describe('adjustedData', () => {
|
||||
expect(adjustedData(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
});
|
||||
it('marks items as pinned from directory pinnedItems names', () => {
|
||||
const input = {
|
||||
type: "directory",
|
||||
path: "/",
|
||||
pinnedItems: ["alpha.txt"],
|
||||
folders: [{ name: "docs", type: "directory" }],
|
||||
files: [
|
||||
{ name: "alpha.txt", type: "file" },
|
||||
{ name: "beta.txt", type: "file" },
|
||||
],
|
||||
source: "Docs",
|
||||
};
|
||||
|
||||
const result = adjustedData(input);
|
||||
|
||||
expect(result.pinnedItems).toBeUndefined();
|
||||
expect(result.items).toEqual([
|
||||
{ isShared: false, name: "docs", path: "/docs/", source: "Docs", type: "directory", pinned: false },
|
||||
{ isShared: false, name: "alpha.txt", path: "/alpha.txt", source: "Docs", type: "file", pinned: true },
|
||||
{ isShared: false, name: "beta.txt", path: "/beta.txt", source: "Docs", type: "file", pinned: false },
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<button
|
||||
v-if="icon === 'close_back'"
|
||||
type="button"
|
||||
:disabled="isDisabled"
|
||||
@click="actionMultiIcon"
|
||||
:aria-label="label"
|
||||
@@ -9,14 +10,15 @@
|
||||
>
|
||||
<svg
|
||||
id="button-toggle-navbar"
|
||||
class="ham hamRotate180 ham5"
|
||||
viewBox="0 0 100 100"
|
||||
width="30"
|
||||
class="ham hamRotate180 ham5"
|
||||
:class="{
|
||||
back: multistate == 'back',
|
||||
close: multistate == 'close',
|
||||
back: multistate === 'back',
|
||||
close: multistate === 'close',
|
||||
}"
|
||||
>
|
||||
<title id="toggle-navbar-title">{{ $t('general.close') }}</title>
|
||||
<path class="line top" d="M 30,33 H 70" />
|
||||
<path class="line middle" d="M 30,50 H 70" />
|
||||
<path class="line bottom" d="M 30,67 H 70" />
|
||||
@@ -24,22 +26,21 @@
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
:disabled="isDisabled"
|
||||
@click="action"
|
||||
:aria-label="label"
|
||||
:title="label"
|
||||
class="action no-select"
|
||||
@click="action"
|
||||
>
|
||||
<i v-if="icon == 'table_rows_narrow' || icon == 'content_copy' || icon == 'file_copy' || icon == 'copy_all'" class="material-symbols-outlined">{{ icon }}</i>
|
||||
<i v-else class="material-symbols">{{ icon }}</i>
|
||||
|
||||
<i :class="iconClass">{{ icon }}</i>
|
||||
<span>{{ label }}</span>
|
||||
<span v-if="counter > 0" class="counter">{{ counter }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mutations, state, getters } from "@/store";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
|
||||
export default {
|
||||
name: "action",
|
||||
@@ -56,7 +57,18 @@ export default {
|
||||
},
|
||||
currentView() {
|
||||
return getters.currentView();
|
||||
}
|
||||
},
|
||||
iconClass() {
|
||||
const outlinedIcons = [
|
||||
'table_rows_narrow',
|
||||
'content_copy',
|
||||
'file_copy',
|
||||
'copy_all'
|
||||
];
|
||||
return outlinedIcons.includes(this.icon)
|
||||
? 'material-symbols-outlined'
|
||||
: 'material-symbols';
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
actionMultiIcon() {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<div @click="preventDefaults" class="button-group">
|
||||
<button v-if="isDisabled" disabled>
|
||||
<button type="button" v-if="isDisabled" disabled>
|
||||
{{ disableMessage }}
|
||||
</button>
|
||||
<template v-else>
|
||||
<button
|
||||
v-for="(btn, index) in buttons"
|
||||
type="button"
|
||||
:key="index"
|
||||
class="clickable"
|
||||
:class="{ active: activeButton === index }"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
id="context-menu"
|
||||
ref="contextMenu"
|
||||
v-if="showContext"
|
||||
:style="centered ? {} : { top: posY + 'px', left: posX + 'px' }"
|
||||
:style="centered ? {} : { top: `${posY}px`, left: `${posX}px` }"
|
||||
class="no-select floating-window"
|
||||
:class="{ 'dark-mode': isDarkMode, 'centered': centered }"
|
||||
:key="showCreate ? 'create-mode' : 'normal-mode'"
|
||||
@@ -76,13 +76,18 @@
|
||||
:label="$t('general.info')"
|
||||
@action="showInfoPrompt"
|
||||
/>
|
||||
|
||||
<action
|
||||
v-if="showDownload"
|
||||
icon="file_download"
|
||||
:label="$t('general.download')"
|
||||
@action="startDownload"
|
||||
/>
|
||||
<action
|
||||
v-if="showSendToApp"
|
||||
icon="ios_share"
|
||||
:label="$t('buttons.sendToApp')"
|
||||
@action="sendToApp"
|
||||
/>
|
||||
<action
|
||||
v-if="showUnarchive"
|
||||
icon="unarchive"
|
||||
@@ -95,6 +100,12 @@
|
||||
:label="$t('general.share')"
|
||||
@action="showSharePrompt"
|
||||
/>
|
||||
<action
|
||||
v-if="showPinAction"
|
||||
icon="push_pin"
|
||||
:label="pinActionLabel"
|
||||
@action="togglePin"
|
||||
/>
|
||||
<action
|
||||
v-if="showRename"
|
||||
icon="edit"
|
||||
@@ -180,6 +191,7 @@
|
||||
<action v-if="isPreview && permissions.modify" icon="edit" :label="$t('general.rename')" @action="showRenamePromptForPreview" />
|
||||
<action v-if="showWatch" icon="visibility" :label="$t('buttons.watchFile')" @action="watchFile()" />
|
||||
<action v-if="hasDownload" icon="file_download" :label="$t('general.download')" @action="startDownload" />
|
||||
<action v-if="showSendToAppInPreview" icon="ios_share" :label="$t('buttons.sendToApp')" @action="sendToAppFromPreview" />
|
||||
<action v-if="showUnarchiveInOverflow" icon="folder_open" :label="$t('prompts.unarchive')" @action="showUnarchivePromptFromPreview" />
|
||||
<action v-if="showEdit" icon="edit" :label="$t('general.edit')" @action="edit()" />
|
||||
<action v-if="markdownPreview" icon="visibility" :label="$t('general.preview')" @action="switchToMarkdown" />
|
||||
@@ -190,15 +202,17 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import downloadFiles from "@/utils/download";
|
||||
import { state, getters, mutations } from "@/store";
|
||||
import { resourcesApi, shareApi, usersApi } from "@/api";
|
||||
import Action from "@/components/Action.vue";
|
||||
import { globalVars } from "@/utils/constants.js";
|
||||
import buttons from "@/utils/buttons";
|
||||
import { notify } from "@/notify";
|
||||
import { resourcesApi } from "@/api";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
import { url } from "@/utils";
|
||||
import buttons from "@/utils/buttons";
|
||||
import { copyToClipboard } from "@/utils/clipboard";
|
||||
import { globalVars } from "@/utils/constants.js";
|
||||
import downloadFiles from "@/utils/download";
|
||||
import { canNativeShare, nativeShareFile } from "@/utils/nativeShare";
|
||||
import { isRichTextPreviewMimeType } from "@/utils/mimetype";
|
||||
|
||||
function isArchivePath(pathOrName) {
|
||||
if (!pathOrName || typeof pathOrName !== "string") return false;
|
||||
@@ -249,7 +263,9 @@ export default {
|
||||
if (state.selected.length === 0) return [];
|
||||
// Map to actual items from state.req
|
||||
if (typeof state.selected[0] === 'number') {
|
||||
return state.selected.map(index => state.req.items[index]);
|
||||
return state.selected
|
||||
.map(index => state.req.items.at(index))
|
||||
.filter(item => item !== null);
|
||||
}
|
||||
return state.selected;
|
||||
},
|
||||
@@ -263,7 +279,7 @@ export default {
|
||||
return this.hasDownload && !this.req.isDir && !this.isShare;
|
||||
},
|
||||
showGoToItem() {
|
||||
return this.showLimitedOptions && this.selectedCount == 1;
|
||||
return this.showLimitedOptions && this.selectedCount === 1;
|
||||
},
|
||||
permissions() {
|
||||
return getters.permissions();
|
||||
@@ -290,8 +306,8 @@ export default {
|
||||
return getters.isShare();
|
||||
},
|
||||
showInfo() {
|
||||
if (this.showLimitedOptions) return this.selectedCount == 1;
|
||||
return !this.showCreate && this.selectedCount == 1;
|
||||
if (this.showLimitedOptions) return this.selectedCount === 1;
|
||||
return !this.showCreate && this.selectedCount === 1;
|
||||
},
|
||||
showDownload() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
@@ -323,9 +339,35 @@ export default {
|
||||
if (this.showLimitedOptions) return false;
|
||||
return this.selectedCount <= 1 && this.showShare;
|
||||
},
|
||||
showSendToApp() {
|
||||
if (!canNativeShare()) return false;
|
||||
if (this.showLimitedOptions || this.showCreate) return false;
|
||||
if (!this.permissions.download || this.selectedCount !== 1) return false;
|
||||
const item = this.firstSelected;
|
||||
return item && !item.isDir && item.type !== "directory";
|
||||
},
|
||||
showSendToAppInPreview() {
|
||||
if (!canNativeShare()) return false;
|
||||
if (!this.hasDownload || this.req?.isDir) return false;
|
||||
return this.isPreview;
|
||||
},
|
||||
showRename() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
return !this.showCreate && this.selectedCount == 1 && this.permissions.modify && !this.isSearchActive;
|
||||
return !this.showCreate && this.selectedCount === 1 && this.permissions.modify && !this.isSearchActive;
|
||||
},
|
||||
showPinAction() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
if (!getters.isLoggedIn()) return false;
|
||||
if (getters.isShare() && !state.shareInfo?.canEditShare) return false;
|
||||
if (this.showCreate || this.isSearchActive) return false;
|
||||
if (this.selectedCount !== 1) return false;
|
||||
return getters.currentView() === "listingView";
|
||||
},
|
||||
pinActionLabel() {
|
||||
return this.isPinnedSelection ? this.$t("buttons.unpinItem") : this.$t("buttons.pinItem");
|
||||
},
|
||||
isPinnedSelection() {
|
||||
return !!this.firstSelected?.pinned;
|
||||
},
|
||||
showCopy() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
@@ -333,10 +375,10 @@ export default {
|
||||
},
|
||||
showCopyPath() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
return !this.showCreate && this.selectedCount == 1 && !!state.user?.showCopyPath;
|
||||
return !this.showCreate && this.selectedCount === 1 && !!state.user?.showCopyPath;
|
||||
},
|
||||
showOpenParentFolder() {
|
||||
return !this.showCreate && this.selectedCount == 1 && (this.isSearchActive || this.showLimitedOptions);
|
||||
return !this.showCreate && this.selectedCount === 1 && (this.isSearchActive || this.showLimitedOptions);
|
||||
},
|
||||
showMove() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
@@ -384,20 +426,20 @@ export default {
|
||||
return false;
|
||||
}
|
||||
const cv = getters.currentView();
|
||||
return cv == "preview" || cv == "markdownViewer" || cv == "editor";
|
||||
return cv === "preview" || cv === "markdownViewer" || cv === "editor";
|
||||
},
|
||||
showEdit() {
|
||||
const cv = getters.currentView();
|
||||
return cv == "markdownViewer" && this.permissions.modify;
|
||||
return cv === "markdownViewer" && this.permissions.modify;
|
||||
},
|
||||
showDelete() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
if (this.selectedCount == 0) {
|
||||
if (this.selectedCount === 0) {
|
||||
return false;
|
||||
}
|
||||
const cv = getters.currentView();
|
||||
return (
|
||||
cv != "settings" &&
|
||||
cv !== "settings" &&
|
||||
!this.isSearchActive &&
|
||||
!!this.permissions.delete
|
||||
);
|
||||
@@ -410,10 +452,10 @@ export default {
|
||||
},
|
||||
showSave() {
|
||||
const allowEdit = this.permissions.modify || (getters.isShare() && state.shareInfo.allowEdit);
|
||||
return getters.currentView() == "editor" && allowEdit;
|
||||
return getters.currentView() === "editor" && allowEdit;
|
||||
},
|
||||
showOverflow() {
|
||||
return getters.currentPromptName() == "OverflowMenu";
|
||||
return getters.currentPromptName() === "OverflowMenu";
|
||||
},
|
||||
showAccess() {
|
||||
if (this.showLimitedOptions) return false;
|
||||
@@ -432,7 +474,7 @@ export default {
|
||||
return this.permissions.share;
|
||||
},
|
||||
showContext() {
|
||||
return getters.currentPromptName() == "ContextMenu";
|
||||
return getters.currentPromptName() === "ContextMenu";
|
||||
},
|
||||
onlyofficeEnabled() {
|
||||
return globalVars.onlyOfficeUrl !== "";
|
||||
@@ -460,7 +502,7 @@ export default {
|
||||
},
|
||||
markdownPreview() {
|
||||
if (getters.currentView() !== 'editor') return false;
|
||||
return state.req.type === 'text/markdown';
|
||||
return isRichTextPreviewMimeType(state.req.type);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
@@ -535,13 +577,13 @@ export default {
|
||||
this.showCreate = !this.showCreate;
|
||||
},
|
||||
shouldShowParentFolder() {
|
||||
return this.isPreview && state.req.path != "/";
|
||||
return this.isPreview && state.req.path !== "/";
|
||||
},
|
||||
showAccessPrompt() {
|
||||
mutations.closeHovers();
|
||||
const item = this.firstSelected;
|
||||
let sourceName = item?.source || state.req.source;
|
||||
let path = item?.path || state.req.path;
|
||||
const sourceName = item?.source || state.req.source;
|
||||
const path = item?.path || state.req.path;
|
||||
mutations.showPrompt({
|
||||
name: "access",
|
||||
props: {
|
||||
@@ -592,7 +634,7 @@ export default {
|
||||
el.style.transition = 'height 0.3s, opacity 0.3s';
|
||||
void el.offsetHeight; // Force reflow
|
||||
// Animate to full height
|
||||
el.style.height = fullHeight + 'px';
|
||||
el.style.height = `${fullHeight}px`;
|
||||
el.style.opacity = '1';
|
||||
setTimeout(() => {
|
||||
this.isAnimating = false;
|
||||
@@ -603,7 +645,7 @@ export default {
|
||||
leave(el, done) {
|
||||
this.isAnimating = true;
|
||||
el.style.transition = 'height 0.3s, opacity 0.3s';
|
||||
el.style.height = el.scrollHeight + 'px';
|
||||
el.style.height = `${el.scrollHeight}px`;
|
||||
void el.offsetHeight;
|
||||
el.style.height = '0';
|
||||
el.style.opacity = '0';
|
||||
@@ -626,7 +668,7 @@ export default {
|
||||
mutations.showPrompt({
|
||||
name: "share",
|
||||
props: {
|
||||
item: this.selectedCount == 1 ? this.firstSelected : state.req
|
||||
item: this.selectedCount === 1 ? this.firstSelected : state.req
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -635,7 +677,7 @@ export default {
|
||||
mutations.showPrompt({
|
||||
name: "rename",
|
||||
props: {
|
||||
item: this.selectedCount == 1 ? this.firstSelected : state.req,
|
||||
item: this.selectedCount === 1 ? this.firstSelected : state.req,
|
||||
parentItems: []
|
||||
},
|
||||
});
|
||||
@@ -674,6 +716,17 @@ export default {
|
||||
const items = this.providedItems;
|
||||
downloadFiles(items);
|
||||
},
|
||||
async sendToApp() {
|
||||
mutations.closeTopPrompt();
|
||||
const item = this.firstSelected;
|
||||
if (!item) return;
|
||||
await nativeShareFile(item);
|
||||
},
|
||||
async sendToAppFromPreview() {
|
||||
mutations.closeTopPrompt();
|
||||
if (!this.req) return;
|
||||
await nativeShareFile(this.req);
|
||||
},
|
||||
showDeletePrompt() {
|
||||
mutations.closeTopPrompt();
|
||||
mutations.showPrompt({
|
||||
@@ -703,6 +756,44 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
async togglePin() {
|
||||
const item = this.firstSelected;
|
||||
if (!item?.name || !getters.isLoggedIn()) {
|
||||
return;
|
||||
}
|
||||
if (getters.isShare() && !state.shareInfo?.canEditShare) {
|
||||
return;
|
||||
}
|
||||
mutations.closeHovers();
|
||||
const directoryPath = state.req?.type === "directory"
|
||||
? state.req.path
|
||||
: url.getParentDir(item.path);
|
||||
const action = item.pinned ? "remove" : "add";
|
||||
try {
|
||||
if (getters.isShare()) {
|
||||
await shareApi.patchPinnedItem({
|
||||
hash: state.shareInfo.hash,
|
||||
path: directoryPath,
|
||||
name: item.name,
|
||||
action,
|
||||
});
|
||||
} else {
|
||||
const source = item.source || state.req?.source || state.sources.current;
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
await usersApi.patchPinnedItem({
|
||||
source,
|
||||
path: directoryPath,
|
||||
name: item.name,
|
||||
action,
|
||||
});
|
||||
}
|
||||
mutations.setReload(true);
|
||||
} catch (e) {
|
||||
notify.showError(e);
|
||||
}
|
||||
},
|
||||
async copyPathToClipboard() {
|
||||
const item = this.firstSelected;
|
||||
const path = item?.path || "";
|
||||
@@ -715,7 +806,7 @@ export default {
|
||||
// If the context menu was triggered on a directory, pass its path as base
|
||||
const selectedItem = this.firstSelected;
|
||||
let base = null;
|
||||
if (selectedItem && selectedItem.isDir) {
|
||||
if (selectedItem?.isDir) {
|
||||
// Pass both path and source
|
||||
base = {
|
||||
path: selectedItem.path,
|
||||
@@ -813,7 +904,7 @@ export default {
|
||||
}
|
||||
buttons.success(button);
|
||||
notify.showSuccessToast(this.$t("editor.fileSaved"));
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// Don't show error notification here - API layer already showed it
|
||||
buttons.done(button);
|
||||
}
|
||||
@@ -824,7 +915,7 @@ export default {
|
||||
let targetPath = state.req.path;
|
||||
let targetSource = state.req.source;
|
||||
const selectedItem = this.firstSelected;
|
||||
if (selectedItem && selectedItem.isDir) {
|
||||
if (selectedItem?.isDir) {
|
||||
targetPath = selectedItem.path;
|
||||
targetSource = selectedItem.source;
|
||||
}
|
||||
|
||||
@@ -5,18 +5,8 @@
|
||||
v-for="notification in notifications"
|
||||
:key="notification.id"
|
||||
:class="['notification-item', notification.type]"
|
||||
@mousedown="startDrag($event, notification.id)"
|
||||
@touchstart="startDrag($event, notification.id)"
|
||||
@mousemove="handleDrag($event, notification.id)"
|
||||
@touchmove="handleDrag($event, notification.id)"
|
||||
@mouseup="endDrag(notification.id)"
|
||||
@touchend="endDrag(notification.id)"
|
||||
@mouseenter="pauseAutoClose(notification.id)"
|
||||
@mouseleave="handleMouseLeave(notification.id)"
|
||||
:style="{
|
||||
transform: `translateX(${notification.dragOffset || 0}px)`,
|
||||
opacity: notification.dragOpacity !== undefined ? notification.dragOpacity : 1
|
||||
}"
|
||||
@mouseleave="resumeAutoClose(notification.id)"
|
||||
>
|
||||
<!-- Close button - always present on every notification, separate from optional buttons array -->
|
||||
<i class="material-symbols" @click="closeNotification(notification.id)">close</i>
|
||||
@@ -29,6 +19,7 @@
|
||||
</div>
|
||||
<div v-if="notification.buttons && notification.buttons.length > 0" class="notification-buttons">
|
||||
<button
|
||||
type="button"
|
||||
v-for="(button, btnIndex) in notification.buttons"
|
||||
:key="btnIndex"
|
||||
:class="['button', button.className]"
|
||||
@@ -62,35 +53,15 @@ import { notify } from "@/notify";
|
||||
|
||||
export default {
|
||||
name: "notifications",
|
||||
data: function () {
|
||||
return {
|
||||
notifications: [],
|
||||
dragState: {
|
||||
isDragging: false,
|
||||
startX: 0,
|
||||
currentX: 0,
|
||||
notificationId: null
|
||||
}
|
||||
};
|
||||
},
|
||||
data: () => ({
|
||||
notifications: []
|
||||
}),
|
||||
mounted() {
|
||||
// Initialize notifications with drag state
|
||||
this.notifications = notify.getNotifications().map(notification => ({
|
||||
...notification,
|
||||
dragOffset: 0,
|
||||
dragOpacity: 1
|
||||
}));
|
||||
// Initialize notifications
|
||||
this.notifications = notify.getNotifications();
|
||||
// Register callback to receive notification updates
|
||||
notify.setUpdateCallback((notifications) => {
|
||||
this.notifications = notifications.map(notification => {
|
||||
// Find existing notification to preserve drag state
|
||||
const existing = this.notifications.find(n => n.id === notification.id);
|
||||
return {
|
||||
...notification,
|
||||
dragOffset: existing?.dragOffset,
|
||||
dragOpacity: existing?.dragOpacity !== undefined ? existing.dragOpacity : 1
|
||||
};
|
||||
});
|
||||
this.notifications = notifications;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
@@ -105,66 +76,6 @@ export default {
|
||||
button.action();
|
||||
}
|
||||
},
|
||||
startDrag(event, notificationId) {
|
||||
const clientX = event.type.includes('touch') ? event.touches[0].clientX : event.clientX;
|
||||
this.dragState = {
|
||||
isDragging: true,
|
||||
startX: clientX,
|
||||
currentX: clientX,
|
||||
notificationId: notificationId
|
||||
};
|
||||
},
|
||||
handleDrag(event, notificationId) {
|
||||
if (!this.dragState.isDragging || this.dragState.notificationId !== notificationId) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
const clientX = event.type.includes('touch') ? event.touches[0].clientX : event.clientX;
|
||||
this.dragState.currentX = clientX;
|
||||
const deltaX = clientX - this.dragState.startX;
|
||||
// Allow dragging in both directions (left and right)
|
||||
const dragOffset = deltaX;
|
||||
const absoluteDeltaX = Math.abs(deltaX);
|
||||
const dragOpacity = Math.max(0.4, 1 - (absoluteDeltaX / 150));
|
||||
// Update the notification position and opacity
|
||||
const notificationIndex = this.notifications.findIndex(n => n.id === notificationId);
|
||||
if (notificationIndex !== -1) {
|
||||
this.notifications[notificationIndex].dragOffset = dragOffset;
|
||||
this.notifications[notificationIndex].dragOpacity = dragOpacity;
|
||||
}
|
||||
},
|
||||
endDrag(notificationId) {
|
||||
if (!this.dragState.isDragging || this.dragState.notificationId !== notificationId) {
|
||||
return;
|
||||
}
|
||||
const deltaX = this.dragState.currentX - this.dragState.startX;
|
||||
const absoluteDeltaX = Math.abs(deltaX);
|
||||
const notificationIndex = this.notifications.findIndex(n => n.id === notificationId);
|
||||
if (notificationIndex !== -1) {
|
||||
// Check if drag distance is enought to close the notification (120px or 25% of screen width)
|
||||
const threshold = Math.min(120, window.innerWidth * 0.25);
|
||||
if (absoluteDeltaX > threshold) {
|
||||
// If the swipe is enought, close
|
||||
this.closeNotification(notificationId);
|
||||
} else {
|
||||
// If not, returnt it back to the original position
|
||||
this.notifications[notificationIndex].dragOffset = 0;
|
||||
this.notifications[notificationIndex].dragOpacity = 1;
|
||||
}
|
||||
}
|
||||
// Reset drag state
|
||||
this.dragState = {
|
||||
isDragging: false,
|
||||
startX: 0,
|
||||
currentX: 0,
|
||||
notificationId: null
|
||||
};
|
||||
},
|
||||
// Handle mouse leave for both drag and auto-close
|
||||
handleMouseLeave(notificationId) {
|
||||
this.endDrag(notificationId);
|
||||
this.resumeAutoClose(notificationId);
|
||||
},
|
||||
// Hover persistence methods
|
||||
pauseAutoClose(notificationId) {
|
||||
notify.pauseAutoClose(notificationId);
|
||||
@@ -207,10 +118,16 @@ export default {
|
||||
transition: right 1s ease;
|
||||
z-index: 21;
|
||||
pointer-events: all;
|
||||
user-select: none;
|
||||
user-select: text;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* selection color for better visibility (since the selection color is the same as --primaryColor) */
|
||||
.notification-item ::selection {
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.notification-content-wrapper {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
@@ -6,7 +6,7 @@ https://raw.githubusercontent.com/dzwillia/vue-simple-progress/master/src/compon
|
||||
<div
|
||||
class="vue-simple-progress-text"
|
||||
:style="text_style"
|
||||
v-if="textPosition == 'middle'"
|
||||
v-if="textPosition === 'middle'"
|
||||
>
|
||||
{{ displayed_text }}
|
||||
</div>
|
||||
@@ -16,7 +16,7 @@ https://raw.githubusercontent.com/dzwillia/vue-simple-progress/master/src/compon
|
||||
<div
|
||||
class="vue-simple-progress-text"
|
||||
:style="text_style"
|
||||
v-if="textPosition == 'inside'"
|
||||
v-if="textPosition === 'inside'"
|
||||
>
|
||||
{{ displayed_text }}
|
||||
<i
|
||||
@@ -32,12 +32,16 @@ https://raw.githubusercontent.com/dzwillia/vue-simple-progress/master/src/compon
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes.js";
|
||||
import { mutations } from "@/store";
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes.js";
|
||||
|
||||
// We're leaving this untouched as you can read in the beginning
|
||||
var isNumber = function (n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
const isNumber = (n) => {
|
||||
const num = Number(n);
|
||||
// Since 'isNaN' nd 'isFinite' are marked as unsafe. We need to do this
|
||||
// to still matching the old behavior (the styling).
|
||||
if (num === 0 && (n === null || n === '' || n === false)) return true;
|
||||
return !Number.isNaN(num) && Number.isFinite(num);
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -120,14 +124,14 @@ export default {
|
||||
pct() {
|
||||
if (!this.isValNumeric) return 100;
|
||||
if (this.max <= 0) return 0;
|
||||
var pct = (this.val / this.max) * 100;
|
||||
const pct = (this.val / this.max) * 100;
|
||||
return Math.max(0, Math.min(pct.toFixed(2), 100));
|
||||
},
|
||||
pctBackground() {
|
||||
if (this.valBackground === null) return 0;
|
||||
if (!isNumber(this.valBackground)) return 0;
|
||||
if (this.max <= 0) return 0;
|
||||
var pct = (this.valBackground / this.max) * 100;
|
||||
const pct = (this.valBackground / this.max) * 100;
|
||||
return Math.max(0, Math.min(pct.toFixed(2), 100));
|
||||
},
|
||||
displayed_text() {
|
||||
@@ -197,21 +201,21 @@ export default {
|
||||
return isNumber(this.fontSize) ? this.fontSize : 13;
|
||||
},
|
||||
progress_style() {
|
||||
var style = {
|
||||
const style = {
|
||||
background: this.bgColor,
|
||||
position: 'relative'
|
||||
};
|
||||
|
||||
if (this.status === 'indexing') {
|
||||
style['background'] = '#fff8d6'; // Muted yellow/amber color
|
||||
style.background = '#fff8d6'; // Muted yellow/amber color
|
||||
}
|
||||
|
||||
if (this.textPosition == "middle" || this.textPosition == "inside") {
|
||||
style["min-height"] = this.size_px + "px";
|
||||
if (this.textPosition === "middle" || this.textPosition === "inside") {
|
||||
style.minHeight = `${this.size_px}px`;
|
||||
}
|
||||
|
||||
if (this.barBorderRadius > 0) {
|
||||
style["border-radius"] = this.barBorderRadius + "px";
|
||||
style.borderRadius = `${this.barBorderRadius}px`;
|
||||
}
|
||||
|
||||
return style;
|
||||
@@ -230,32 +234,32 @@ export default {
|
||||
if (percentage < 1) {
|
||||
percentage = 0;
|
||||
}
|
||||
var style = {
|
||||
width: percentage + "%",
|
||||
height: this.size_px + "px",
|
||||
const style = {
|
||||
width: `${percentage}%`,
|
||||
height: `${this.size_px}px`,
|
||||
background: barColor,
|
||||
transition: this.barTransition,
|
||||
position: this.valBackground !== null ? 'relative' : undefined,
|
||||
"z-index": this.valBackground !== null ? 1 : undefined,
|
||||
zIndex: this.valBackground !== null ? 1 : undefined,
|
||||
};
|
||||
|
||||
// Add pulse animation for indexing status
|
||||
if (this.status === 'indexing') {
|
||||
style['animation'] = 'progress-pulse 4s ease-in-out infinite';
|
||||
style['background'] = 'rgb(237 161 41)'; // orange
|
||||
style.animation = 'progress-pulse 4s ease-in-out infinite';
|
||||
style.background = 'rgb(237 161 41)'; // orange
|
||||
}
|
||||
|
||||
if (this.barBorderRadius > 0) {
|
||||
style["border-radius"] = this.barBorderRadius + "px";
|
||||
style.borderRadius = `${this.barBorderRadius}px`;
|
||||
}
|
||||
|
||||
if (this.textPosition == "middle") {
|
||||
style["position"] = "absolute";
|
||||
style["top"] = "0";
|
||||
style["height"] = "100%";
|
||||
style["min-width"] = "1.5em";
|
||||
style["min-height"] = this.size_px + "px";
|
||||
style["z-index"] = "-1";
|
||||
if (this.textPosition === "middle") {
|
||||
style.position = 'absolute';
|
||||
style.top = '0';
|
||||
style.height = '100%';
|
||||
style.minWidth = '1.5em';
|
||||
style.minHeight = `${this.size_px}px`;
|
||||
style.zIndex = '-1';
|
||||
}
|
||||
|
||||
return style;
|
||||
@@ -265,9 +269,9 @@ export default {
|
||||
if (percentage < 1) {
|
||||
percentage = 0;
|
||||
}
|
||||
var style = {
|
||||
width: percentage + "%",
|
||||
height: this.size_px + "px",
|
||||
const style = {
|
||||
width: `${percentage}%`,
|
||||
height: `${this.size_px}px`,
|
||||
background: '#9e9e9e',
|
||||
transition: this.barTransition,
|
||||
position: 'absolute',
|
||||
@@ -276,40 +280,40 @@ export default {
|
||||
};
|
||||
|
||||
if (this.barBorderRadius > 0) {
|
||||
style["border-radius"] = this.barBorderRadius + "px";
|
||||
style.borderRadius = `${this.barBorderRadius}px`;
|
||||
}
|
||||
|
||||
return style;
|
||||
},
|
||||
text_style() {
|
||||
var style = {
|
||||
const style = {
|
||||
"color": this.textFgColor,
|
||||
"font-size": this.text_font_size + "px",
|
||||
"font-size": `${this.text_font_size}px`,
|
||||
"text-align": this.textAlign,
|
||||
};
|
||||
|
||||
if (this.textPosition === 'inside') {
|
||||
style['position'] = 'absolute';
|
||||
style['left'] = '0';
|
||||
style['right'] = '0';
|
||||
style['top'] = '50%';
|
||||
style['transform'] = 'translateY(-50%)';
|
||||
style['width'] = '100%';
|
||||
style['padding'] = '0 0.5em';
|
||||
style['box-sizing'] = 'border-box';
|
||||
style['z-index'] = this.valBackground !== null ? 2 : undefined;
|
||||
style.position = 'absolute';
|
||||
style.left = '0';
|
||||
style.right = '0';
|
||||
style.top = '50%';
|
||||
style.transform = 'translateY(-50%)';
|
||||
style.width = '100%';
|
||||
style.padding = '0 0.5em';
|
||||
style.boxSizing = 'border-box';
|
||||
style.zIndex = this.valBackground !== null ? 2 : undefined;
|
||||
}
|
||||
|
||||
if (
|
||||
this.textPosition == "top" ||
|
||||
this.textPosition == "middle"
|
||||
this.textPosition === "top" ||
|
||||
this.textPosition === "middle"
|
||||
)
|
||||
style["padding-bottom"] = this.text_padding + "px";
|
||||
style.paddingBottom = `${this.text_padding}px`;
|
||||
if (
|
||||
this.textPosition == "bottom" ||
|
||||
this.textPosition == "middle"
|
||||
this.textPosition === "bottom" ||
|
||||
this.textPosition === "middle"
|
||||
)
|
||||
style["padding-top"] = this.text_padding + "px";
|
||||
style.paddingTop = `${this.text_padding}px`;
|
||||
return style;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!-- Search input section -->
|
||||
<div class="search-input-container">
|
||||
<!-- Close button visible when search is active -->
|
||||
<button v-if="active" class="action" @click="close" :aria-label="$t('general.close')"
|
||||
<button v-if="active" type="button" class="action" @click="close" :aria-label="$t('general.close')"
|
||||
:title="$t('general.close')">
|
||||
<i class="material-symbols">close</i>
|
||||
</button>
|
||||
@@ -85,6 +85,12 @@
|
||||
:name="$t('search.useWildcardSearch')"
|
||||
:description="$t('search.useWildcardSearchDescription')"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
class="item"
|
||||
v-model="caseExactSearch"
|
||||
:name="$t('search.caseExact')"
|
||||
:description="$t('search.caseExactDescription')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</SettingsItem>
|
||||
@@ -109,7 +115,7 @@
|
||||
:hasPreview="showPreviewImages && (s.hasPreview || false)"
|
||||
:thumbnailUrl="showPreviewImages ? getThumbnailUrl(s) : ''" />
|
||||
<span class="text-container">
|
||||
{{ basePath(s.path, s.type == "directory") }}{{ baseName(s.path) }}
|
||||
{{ basePath(s.path, s.type === "directory") }}{{ baseName(s.path) }}
|
||||
<!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
|
||||
</span>
|
||||
<div class="filesize">{{ humanSize(s.size) }}</div>
|
||||
@@ -130,20 +136,20 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ButtonGroup from "./ButtonGroup.vue";
|
||||
import { toolsApi, resourcesApi } from "@/api";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes";
|
||||
import { url } from "@/utils/";
|
||||
import { resourcesApi, toolsApi } from "@/api";
|
||||
import Icon from "@/components/files/Icon.vue";
|
||||
import ToggleSwitch from "@/components/settings/ToggleSwitch.vue";
|
||||
import SettingsItem from "@/components/settings/SettingsItem.vue";
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import LoadingSpinner from "@/components/LoadingSpinner.vue";
|
||||
import { utcStartOfDaySecondsFromDateInput } from "@/utils/moment";
|
||||
import SettingsItem from "@/components/settings/SettingsItem.vue";
|
||||
import ToggleSwitch from "@/components/settings/ToggleSwitch.vue";
|
||||
import router from "@/router";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
import { url } from "@/utils/";
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes";
|
||||
import { utcStartOfDaySecondsFromDateInput } from "@/utils/moment";
|
||||
import ButtonGroup from "./ButtonGroup.vue";
|
||||
|
||||
var boxes = {
|
||||
const boxes = {
|
||||
folder: { label: "folders", icon: "folder" },
|
||||
file: { label: "files", icon: "insert_drive_file" },
|
||||
archive: { label: "archives", icon: "archive" },
|
||||
@@ -173,6 +179,7 @@ export default {
|
||||
isTypeSelectDisabled: false,
|
||||
showPreviewImages: false,
|
||||
useWildcardSearch: false,
|
||||
caseExactSearch: false,
|
||||
folderSelect: [
|
||||
{ label: this.$t("search.onlyFolders"), value: "type:folder" },
|
||||
{ label: this.$t("search.onlyFiles"), value: "type:file" },
|
||||
@@ -212,6 +219,9 @@ export default {
|
||||
useWildcardSearch() {
|
||||
this.submit();
|
||||
},
|
||||
caseExactSearch() {
|
||||
this.submit();
|
||||
},
|
||||
searchTypes() {
|
||||
this.submit();
|
||||
},
|
||||
@@ -281,7 +291,7 @@ export default {
|
||||
return getters.eventTheme();
|
||||
},
|
||||
disableSearchOptions() {
|
||||
return state.user.disableSearchOptions;
|
||||
return state.user?.disableSearchOptions;
|
||||
},
|
||||
foldersOnly() {
|
||||
return this.isTypeSelectDisabled;
|
||||
@@ -293,7 +303,7 @@ export default {
|
||||
return getters.isDarkMode();
|
||||
},
|
||||
showBoxes() {
|
||||
return this.searchTypes == "";
|
||||
return this.searchTypes === "";
|
||||
},
|
||||
boxes() {
|
||||
return boxes;
|
||||
@@ -322,7 +332,7 @@ export default {
|
||||
// Construct the same full path as addSelected does
|
||||
const context = url.removeTrailingSlash(this.getContext);
|
||||
const pathStr = url.removeLeadingSlash(url.removeTrailingSlash(result.path));
|
||||
const fullPath = context + '/' + pathStr;
|
||||
const fullPath = `${context}/${pathStr}`;
|
||||
return selectedPaths.has(fullPath);
|
||||
});
|
||||
},
|
||||
@@ -340,7 +350,7 @@ export default {
|
||||
if (this.selectedSource === "__all__" || (this.selectedSource === "" && this.multipleSources)) {
|
||||
return "/";
|
||||
}
|
||||
let result = url.extractSourceFromPath(decodeURIComponent(state.route.path));
|
||||
const result = url.extractSourceFromPath(decodeURIComponent(state.route.path));
|
||||
if (this.selectedSource === "" || result.source === this.selectedSource) {
|
||||
return result.path;
|
||||
} else {
|
||||
@@ -403,7 +413,7 @@ export default {
|
||||
},
|
||||
updateSource(event) {
|
||||
this.selectedSource = event.target.value;
|
||||
this.submit();
|
||||
void this.submit();
|
||||
},
|
||||
getItemUrl(s) {
|
||||
// Use source from result if available, otherwise fall back to selectedSource
|
||||
@@ -412,7 +422,7 @@ export default {
|
||||
// Ensure exactly one slash between context and path
|
||||
const context = url.removeTrailingSlash(this.getContext);
|
||||
const path = url.removeLeadingSlash(url.removeTrailingSlash(s.path));
|
||||
const fullPath = context + '/' + path;
|
||||
const fullPath = `${context}/${path}`;
|
||||
return url.buildItemUrl(source, fullPath, true);
|
||||
},
|
||||
humanSize(size) {
|
||||
@@ -423,11 +433,11 @@ export default {
|
||||
if (!isDir) {
|
||||
result = url.removeLeadingSlash(result); // fix weird rtl thing
|
||||
}
|
||||
return result + "/";
|
||||
return `${result}/`;
|
||||
},
|
||||
baseName(str) {
|
||||
let parts = url.removeTrailingSlash(str).split("/");
|
||||
let part = parts.pop();
|
||||
const parts = url.removeTrailingSlash(str).split("/");
|
||||
const part = parts.pop();
|
||||
return part;
|
||||
},
|
||||
/** Clear query state whenever the overlay opens (open paths do not always call close()). */
|
||||
@@ -449,16 +459,15 @@ export default {
|
||||
this.close(event);
|
||||
return;
|
||||
}
|
||||
this.results.length === 0;
|
||||
},
|
||||
addToTypes(string) {
|
||||
if (this.searchTypes.includes(string)) {
|
||||
return true;
|
||||
}
|
||||
if (string == null || string == "") {
|
||||
if (string === null || string === "") {
|
||||
return false;
|
||||
}
|
||||
this.searchTypes = this.searchTypes + string + " ";
|
||||
this.searchTypes = `${this.searchTypes + string} `;
|
||||
},
|
||||
resetSearchFilters() {
|
||||
this.searchTypes = "";
|
||||
@@ -466,10 +475,10 @@ export default {
|
||||
this.showPreviewImages = false;
|
||||
},
|
||||
removeFromTypes(string) {
|
||||
if (string == null || string == "") {
|
||||
if (string === null || string === "") {
|
||||
return false;
|
||||
}
|
||||
this.searchTypes = this.searchTypes.replaceAll(string + " ", "");
|
||||
this.searchTypes = this.searchTypes.replaceAll(`${string} `, "");
|
||||
if (state.isMobile) {
|
||||
this.$refs.input.focus();
|
||||
}
|
||||
@@ -482,7 +491,7 @@ export default {
|
||||
},
|
||||
async submit(event) {
|
||||
this.results = [];
|
||||
if (event != undefined) {
|
||||
if (event !== undefined) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (this.value === "" || this.value.length < globalVars.minSearchLength) {
|
||||
@@ -490,11 +499,11 @@ export default {
|
||||
return;
|
||||
}
|
||||
let searchTypesFull = this.searchTypes;
|
||||
if (this.largerThan != "") {
|
||||
searchTypesFull = searchTypesFull + "type:largerThan=" + this.largerThan + " ";
|
||||
if (this.largerThan !== "") {
|
||||
searchTypesFull = `${searchTypesFull}type:largerThan=${this.largerThan} `;
|
||||
}
|
||||
if (this.smallerThan != "") {
|
||||
searchTypesFull = searchTypesFull + "type:smallerThan=" + this.smallerThan + " ";
|
||||
if (this.smallerThan !== "") {
|
||||
searchTypesFull = `${searchTypesFull}type:smallerThan=${this.smallerThan} `;
|
||||
}
|
||||
const dateParams = {};
|
||||
const olderUnix = utcStartOfDaySecondsFromDateInput(this.modifiedOlderThan);
|
||||
@@ -508,10 +517,17 @@ export default {
|
||||
if (this.useWildcardSearch) {
|
||||
dateParams.useWildcard = true;
|
||||
}
|
||||
let searchQuery = searchTypesFull + this.value;
|
||||
if (this.caseExactSearch) {
|
||||
searchQuery =
|
||||
searchTypesFull.trim() === ""
|
||||
? `case:exact ${this.value}`
|
||||
: `case:exact ${searchTypesFull}${this.value}`;
|
||||
}
|
||||
this.ongoing++;
|
||||
|
||||
// Determine which sources to search
|
||||
let sourcesToSearch = [];
|
||||
let sourcesToSearch;
|
||||
if (this.selectedSource === "__all__" || this.selectedSource === "") {
|
||||
// Search all sources
|
||||
sourcesToSearch = Object.keys(this.sourceInfo);
|
||||
@@ -526,13 +542,13 @@ export default {
|
||||
this.results = await toolsApi.search(
|
||||
scope,
|
||||
sourcesToSearch,
|
||||
searchTypesFull + this.value,
|
||||
searchQuery,
|
||||
false,
|
||||
dateParams
|
||||
);
|
||||
|
||||
this.ongoing--;
|
||||
if (this.results.length == 0 && this.ongoing == 0) {
|
||||
if (this.results.length === 0 && this.ongoing === 0) {
|
||||
this.noneMessage = this.$t("search.noResults");
|
||||
}
|
||||
},
|
||||
@@ -561,10 +577,10 @@ export default {
|
||||
// Ensure exactly one slash between context and path
|
||||
const context = url.removeTrailingSlash(this.getContext);
|
||||
const path = url.removeLeadingSlash(url.removeTrailingSlash(s.path));
|
||||
const fullPath = context + '/' + path;
|
||||
const fullPath = `${context}/${path}`;
|
||||
const modified = s.modified || "";
|
||||
return resourcesApi.getPreviewURL(source, fullPath, modified);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
@@ -589,7 +605,7 @@ export default {
|
||||
});
|
||||
},
|
||||
openInAdvancedSearch() {
|
||||
let sourcesToSearch = [];
|
||||
let sourcesToSearch;
|
||||
if (this.selectedSource === "__all__" || this.selectedSource === "") {
|
||||
sourcesToSearch = Object.keys(this.sourceInfo || {});
|
||||
} else {
|
||||
@@ -621,6 +637,9 @@ export default {
|
||||
if (this.useWildcardSearch) {
|
||||
query.wildcard = "1";
|
||||
}
|
||||
if (this.caseExactSearch) {
|
||||
query.caseExact = "1";
|
||||
}
|
||||
if (this.isTypeSelectDisabled) {
|
||||
query.typeLock = "1";
|
||||
}
|
||||
@@ -663,7 +682,7 @@ export default {
|
||||
// Combine context (scope) with the result path - ensure exactly one slash between
|
||||
const context = url.removeTrailingSlash(this.getContext);
|
||||
const pathStr = url.removeLeadingSlash(url.removeTrailingSlash(s.path));
|
||||
let path = context + '/' + pathStr;
|
||||
const path = `${context}/${pathStr}`;
|
||||
const modifiedItem = {
|
||||
name: pathParts.pop(),
|
||||
path: path,
|
||||
@@ -746,11 +765,7 @@ export default {
|
||||
-webkit-animation: SlideDown 0.5s forwards;
|
||||
animation: SlideDown 0.5s forwards;
|
||||
border-radius: 1em;
|
||||
max-height: 100%;
|
||||
border-top: none;
|
||||
border-top-width: initial;
|
||||
border-top-style: none;
|
||||
border-top-color: initial;
|
||||
border-top-left-radius: 0px;
|
||||
border-top-right-radius: 0px;
|
||||
border: 2px solid var(--surfaceSecondary);
|
||||
@@ -799,7 +814,6 @@ export default {
|
||||
.search-input-container {
|
||||
background-color: rgba(100, 100, 100, 0.2);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
padding: 0.5em 0.75em;
|
||||
border-radius: 1em;
|
||||
border-style: unset;
|
||||
@@ -910,8 +924,7 @@ export default {
|
||||
text-align: left;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
height: 0;
|
||||
transition: 2s ease height, 2s ease padding;
|
||||
transition: 2s ease width, 2s ease padding;
|
||||
transition: 2s ease height, 2s ease padding, 2s ease width, 2s ease padding;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
import Breadcrumbs from "@/components/files/Breadcrumbs.vue";
|
||||
import ListingHeader from "@/components/files/ListingHeader.vue";
|
||||
import DuplicateFinderActions from "@/components/tools/DuplicateFinderActions.vue";
|
||||
import { state, getters } from "@/store";
|
||||
import { getters, state } from "@/store";
|
||||
import { eventBus } from "@/store/eventBus";
|
||||
|
||||
export default {
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
// Check if any file has duration metadata
|
||||
if (!state.req?.items) return false;
|
||||
return state.req.items.some(item =>
|
||||
item.type !== 'directory' && item.metadata && item.metadata.duration
|
||||
item.type !== 'directory' && item.metadata?.duration
|
||||
);
|
||||
},
|
||||
showDuplicateFinderActions() {
|
||||
@@ -88,7 +88,7 @@ export default {
|
||||
moveWithSidebar() {
|
||||
if (getters.isStickySidebar() && getters.isSidebarVisible()) {
|
||||
return {
|
||||
left: state.sidebar.width + 'em',
|
||||
left: `${state.sidebar.width}em`,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state, getters, mutations } from "@/store";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes";
|
||||
|
||||
export default {
|
||||
name: "StatusBar",
|
||||
data() {
|
||||
return {
|
||||
gallerySize: state.user.gallerySize,
|
||||
gallerySize: state.user?.gallerySize,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -91,9 +91,9 @@ export default {
|
||||
}
|
||||
let total = 0;
|
||||
state.selected.forEach(index => {
|
||||
if (index >= 0 && index < state.req.items.length) {
|
||||
const item = state.req.items[index];
|
||||
if (item && item.size) {
|
||||
if (index >= 0 && index < state.req?.items.length) {
|
||||
const item = state.req.items.at(index);
|
||||
if (item?.size) {
|
||||
total += item.size;
|
||||
}
|
||||
}
|
||||
@@ -133,29 +133,27 @@ export default {
|
||||
if (dirs === 0 && files === 0) {
|
||||
return this.$t('files.lonely');
|
||||
}
|
||||
let parts = [];
|
||||
const parts = [];
|
||||
if (dirs > 0) parts.push(`${dirs} ${this.foldersLabel}`);
|
||||
if (files > 0) parts.push(`${files} ${this.filesLabel}`);
|
||||
|
||||
return parts.join(' | ') + ' ' + sizeText;
|
||||
return `${parts.join(' | ')} ${sizeText}`;
|
||||
},
|
||||
moveWithSidebar() {
|
||||
if (getters.isStickySidebar() && getters.isSidebarVisible()) {
|
||||
return {
|
||||
left: state.sidebar.width + 'em',
|
||||
left: `${state.sidebar.width}em`,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
},
|
||||
editorStatsText() {
|
||||
const { lines, words, chars } = state.editorStats;
|
||||
return [
|
||||
[words, chars]
|
||||
.map((v, i) => v != null && this.$t(i === 0 ? 'editor.words' : 'editor.chars', { count: v }))
|
||||
.filter(Boolean)
|
||||
.join(', '),
|
||||
lines != null && this.$t('editor.lines', { count: lines })
|
||||
].filter(Boolean).join(' | ');
|
||||
const parts = [];
|
||||
if (words !== null) parts.push(this.$t('editor.words', { count: words }));
|
||||
if (chars !== null) parts.push(this.$t('editor.chars', { count: chars }));
|
||||
if (lines !== null) parts.push(this.$t('editor.lines', { count: lines }));
|
||||
return parts.join(' | ');
|
||||
},
|
||||
editorFontSize: {
|
||||
get() {
|
||||
@@ -208,7 +206,7 @@ export default {
|
||||
// Only update if the mode actually changed
|
||||
if (newMode !== currentMode) {
|
||||
mutations.updateDisplayPreferences({ viewMode: newMode });
|
||||
mutations.updateCurrentUser({ viewMode: newMode });
|
||||
void mutations.updateCurrentUser({ viewMode: newMode });
|
||||
}
|
||||
},
|
||||
// Ctrl + Mouse Wheel to adjust the slider sizes
|
||||
@@ -217,10 +215,10 @@ export default {
|
||||
|
||||
const delta = event.deltaY > 0 ? 1 : -1; // Scroll down increases, up decreases
|
||||
|
||||
const advSearch = (state.route?.path || "").startsWith("/tools/advancedSearch");
|
||||
const advSearch = (state.route.path || "").startsWith("/tools/advancedSearch");
|
||||
if (this.currentView === "listingView" || advSearch) {
|
||||
event.preventDefault();
|
||||
let newSize = Math.min(9, Math.max(1, this.gallerySize - delta));
|
||||
const newSize = Math.min(9, Math.max(1, this.gallerySize - delta));
|
||||
if (newSize !== this.gallerySize) {
|
||||
this.gallerySize = newSize;
|
||||
mutations.setGallerySize(newSize);
|
||||
@@ -228,7 +226,7 @@ export default {
|
||||
}
|
||||
} else if (this.currentView === 'editor') {
|
||||
event.preventDefault();
|
||||
let newSize = Math.min(24, Math.max(8, this.editorFontSize - delta));
|
||||
const newSize = Math.min(24, Math.max(8, this.editorFontSize - delta));
|
||||
if (newSize !== this.editorFontSize) {
|
||||
this.editorFontSize = newSize;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state, getters, mutations } from "@/store";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
|
||||
export default {
|
||||
name: "Tooltip",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<!-- Lock button -->
|
||||
<button
|
||||
v-if="lyrics.length && syncedLyrics"
|
||||
type="button"
|
||||
class="lyrics-lock-btn"
|
||||
@click="lyricsScrollLocked = !lyricsScrollLocked"
|
||||
:title="lyricsScrollLocked ? $t('player.unlockLyrics') : $t('player.lockLyrics')"
|
||||
@@ -46,7 +47,7 @@
|
||||
@click.stop="syncedLyrics && $emit('seek', line.timestamp)"
|
||||
:role="syncedLyrics ? 'button' : undefined"
|
||||
:tabindex="syncedLyrics ? 0 : undefined"
|
||||
:aria-label="syncedLyrics ? 'Seek to ' + line.text : undefined"
|
||||
:aria-label="syncedLyrics ? `Seek to ${line.text}` : undefined"
|
||||
>
|
||||
{{ line.text }}
|
||||
</p>
|
||||
@@ -84,7 +85,7 @@ export default {
|
||||
computed: {
|
||||
darkMode() { return getters.isDarkMode(); },
|
||||
queueCount() {
|
||||
return state.playbackQueue?.queue?.length || 0;
|
||||
return state.playbackQueue.queue.length || 0;
|
||||
},
|
||||
syncedLyrics() {
|
||||
return this.lyrics.length > 0 && !this.lyrics.every(line => line.timestamp === 0);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<li class="item" v-for="(link, index) in items" :key="index">
|
||||
<router-link
|
||||
:to="link.url"
|
||||
:aria-label="'breadcrumb-link-' + link.name"
|
||||
:aria-label="`breadcrumb-link-${link.name}`"
|
||||
:title="link.name"
|
||||
:key="index"
|
||||
:class="{ changeAvailable: hasUpdate,
|
||||
@@ -32,10 +32,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state, getters, mutations } from "@/store";
|
||||
import { url } from "@/utils";
|
||||
import { resourcesApi } from "@/api";
|
||||
import { notify } from "@/notify";
|
||||
import { getters, mutations, state } from "@/store";
|
||||
import { url } from "@/utils";
|
||||
import { getObjectProperty } from '@/utils/object.js';
|
||||
import { goToItemNotificationButton } from "@/utils/notificationActions";
|
||||
|
||||
export default {
|
||||
name: "breadcrumbs",
|
||||
@@ -69,7 +71,7 @@ export default {
|
||||
return state.req.hasUpdate;
|
||||
},
|
||||
isDroppable() {
|
||||
return getters.permissions()?.modify
|
||||
return getters.permissions().modify
|
||||
},
|
||||
homeLink() {
|
||||
return {
|
||||
@@ -80,17 +82,15 @@ export default {
|
||||
};
|
||||
},
|
||||
scrollRatio() {
|
||||
const ratio = state.listing?.scrollRatio || 0;
|
||||
const ratio = state.listing.scrollRatio || 0;
|
||||
return ratio;
|
||||
},
|
||||
items() {
|
||||
const req = state.req;
|
||||
if (!req.items || !req.path) {
|
||||
return [];
|
||||
}
|
||||
let encodedPathString = url.encodedPath(state.req.path);
|
||||
let originalParts = state.req.path.split("/");
|
||||
let encodedParts = encodedPathString.split("/");
|
||||
if (!req.path) return [];
|
||||
const encodedPathString = url.encodedPath(state.req.path);
|
||||
const originalParts = state.req.path.split("/");
|
||||
const encodedParts = encodedPathString.split("/");
|
||||
// Remove empty strings from both arrays consistently
|
||||
if (originalParts[0] === "") {
|
||||
originalParts.shift();
|
||||
@@ -100,14 +100,14 @@ export default {
|
||||
originalParts.pop();
|
||||
encodedParts.pop();
|
||||
}
|
||||
let breadcrumbs = [];
|
||||
const breadcrumbs = [];
|
||||
let buildRef = this.base;
|
||||
let accumulatedPath = "";
|
||||
|
||||
for (let i = 0; i < originalParts.length; i++) {
|
||||
const origPart = originalParts[i];
|
||||
const encodedElement = encodedParts[i];
|
||||
buildRef = buildRef + encodedElement + "/";
|
||||
const origPart = getObjectProperty(originalParts, i);
|
||||
const encodedElement = getObjectProperty(encodedParts, i);
|
||||
buildRef = `${buildRef + encodedElement}/`;
|
||||
accumulatedPath = accumulatedPath ? `${accumulatedPath}/${origPart}` : origPart;
|
||||
|
||||
breadcrumbs.push({
|
||||
@@ -207,10 +207,10 @@ export default {
|
||||
|
||||
// Build list of items to move from selected items
|
||||
let itemsToMove = [];
|
||||
for (let i of state.selected) {
|
||||
for (const i of state.selected) {
|
||||
if (i < 0 || i >= state.req.length) continue;
|
||||
|
||||
const selectedItem = state.req.items[i];
|
||||
const selectedItem = state.req.items.at(i);
|
||||
|
||||
let fromPath = selectedItem.path;
|
||||
|
||||
@@ -238,7 +238,7 @@ export default {
|
||||
const toDir = normalizePath(item.to);
|
||||
|
||||
// Check if destination is inside the directory
|
||||
if (toDir.startsWith(fromDir + "/")) {
|
||||
if (toDir.startsWith(`${fromDir}/`)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ export default {
|
||||
const response = await resourcesApi.fetchFiles(source, targetPath);
|
||||
targetDirItems = response?.items;
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_e) {
|
||||
notify.showError(this.$t("files.cannotAccesDir"));
|
||||
return;
|
||||
}
|
||||
@@ -279,21 +279,20 @@ export default {
|
||||
await resourcesApi.moveCopy(itemsToMove, "move", overwrite, rename);
|
||||
}
|
||||
|
||||
const buttonAction = () => {
|
||||
url.goToItem(source, targetPath, {}, false, getters.isShare());
|
||||
};
|
||||
|
||||
notify.showSuccess(this.$t("prompts.moveSuccess"), {
|
||||
icon: "folder",
|
||||
buttons: [{
|
||||
label: this.$t("buttons.goToItem"),
|
||||
primary: true,
|
||||
action: buttonAction
|
||||
}]
|
||||
buttons: [
|
||||
goToItemNotificationButton(
|
||||
this.$t("buttons.goToItem"),
|
||||
source,
|
||||
targetPath,
|
||||
getters.isShare()
|
||||
),
|
||||
],
|
||||
});
|
||||
mutations.closeTopPrompt();
|
||||
mutations.setReload(true);
|
||||
} catch (error) {
|
||||
} catch (_e) {
|
||||
mutations.closeTopPrompt();
|
||||
notify.showError(this.$t("prompts.moveFailed"));
|
||||
}
|
||||
@@ -308,7 +307,7 @@ export default {
|
||||
const rename = option === "rename";
|
||||
event.preventDefault();
|
||||
mutations.closeTopPrompt();
|
||||
moveAction(overwrite, rename);
|
||||
void moveAction(overwrite, rename);
|
||||
},
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state, mutations, getters } from '@/store';
|
||||
import throttle from "@/utils/throttle";
|
||||
import { notify } from "@/notify";
|
||||
import LoadingSpinner from "@/components/LoadingSpinner.vue";
|
||||
import { notify } from "@/notify";
|
||||
import { getters, mutations, state } from '@/store';
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import { getBestCachedImage } from "@/utils/imageCache";
|
||||
import { isRawImageMimeType } from "@/utils/mimetype";
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import throttle from "@/utils/throttle";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -95,6 +95,7 @@ export default {
|
||||
edgeCommitX: 130,
|
||||
edgeCommitY: 110,
|
||||
edgeRubberMax: 100,
|
||||
pinchActive: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -127,7 +128,7 @@ export default {
|
||||
return getBestCachedImage(source, this.path, state.req?.modified);
|
||||
},
|
||||
navigationGestureAllowed() {
|
||||
return state.navigation.enabled && getters.currentPrompt() == null;
|
||||
return state.navigation.enabled && getters.currentPrompt() === null;
|
||||
},
|
||||
hasImagePrevious() {
|
||||
return this.navigationGestureAllowed && state.navigation.previousLink !== '';
|
||||
@@ -174,8 +175,10 @@ export default {
|
||||
});
|
||||
}
|
||||
|
||||
let container = this.$refs.container;
|
||||
this.classList.forEach((className) => container.classList.add(className));
|
||||
const container = this.$refs.container;
|
||||
this.classList.forEach((className) => {
|
||||
container.classList.add(className);
|
||||
});
|
||||
if (getComputedStyle(container).width === "0px") {
|
||||
container.style.width = "100%";
|
||||
}
|
||||
@@ -191,6 +194,10 @@ export default {
|
||||
clearTimeout(this.loadTimeout);
|
||||
this.loadTimeout = null;
|
||||
}
|
||||
if (this.disabledTimer) {
|
||||
clearTimeout(this.disabledTimer);
|
||||
this.disabledTimer = null;
|
||||
}
|
||||
this.teardownEdgeMouseListeners();
|
||||
mutations.setNavigationGestureHint({});
|
||||
window.removeEventListener("resize", this.onResize);
|
||||
@@ -251,7 +258,7 @@ export default {
|
||||
const actualSrc = img?.src || '';
|
||||
|
||||
// If the error is due to & in URL, try to fix it
|
||||
if (actualSrc && actualSrc.includes('&')) {
|
||||
if (actualSrc?.includes('&')) {
|
||||
const fixedSrc = actualSrc.replace(/&/g, '&');
|
||||
if (img) {
|
||||
img.src = fixedSrc;
|
||||
@@ -284,7 +291,7 @@ export default {
|
||||
imgex.src = URL.createObjectURL(blob);
|
||||
imgex.onload = () => URL.revokeObjectURL(imgex.src);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_e) {
|
||||
notify.showError("Error decoding TIFF");
|
||||
}
|
||||
},
|
||||
@@ -537,7 +544,7 @@ export default {
|
||||
setCenter() {
|
||||
const container = this.$refs.container;
|
||||
const img = this.$refs.imgex;
|
||||
if (!container || !img || !img.clientWidth || !img.clientHeight) {
|
||||
if (!container || !img?.clientWidth || !img?.clientHeight) {
|
||||
return;
|
||||
}
|
||||
this.position.relative = { x: 0, y: 0 };
|
||||
@@ -585,6 +592,13 @@ export default {
|
||||
this.lastX = null;
|
||||
this.lastY = null;
|
||||
this.lastTouchDistance = null;
|
||||
if (event.targetTouches.length >= 2) {
|
||||
this.pinchActive = true;
|
||||
this.resetEdgeGestureImmediate();
|
||||
this.applyImgTransform();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (event.targetTouches.length === 1 && this.scale === 1) {
|
||||
const touch = event.targetTouches[0];
|
||||
this.edgeStartX = touch.pageX;
|
||||
@@ -597,7 +611,7 @@ export default {
|
||||
this.resetEdgeGestureImmediate();
|
||||
this.applyImgTransform();
|
||||
}
|
||||
if (event.targetTouches.length < 2) {
|
||||
if (event.targetTouches.length === 2) {
|
||||
setTimeout(() => {
|
||||
this.touches = 0;
|
||||
}, 300);
|
||||
@@ -620,7 +634,6 @@ export default {
|
||||
this.scale = 4;
|
||||
break;
|
||||
default:
|
||||
case 4:
|
||||
this.scale = 1;
|
||||
this.setCenter();
|
||||
break;
|
||||
@@ -631,7 +644,34 @@ export default {
|
||||
touchMove(event) {
|
||||
// Default is prevented via @touchmove.prevent so the browser cannot steal
|
||||
// vertical drags (pull-to-refresh) before our edge-gesture thresholds.
|
||||
if (event.targetTouches.length === 1 && this.scale === 1) {
|
||||
if (event.targetTouches.length === 2) {
|
||||
if (!this.pinchActive) {
|
||||
this.pinchActive = true;
|
||||
this.resetEdgeGestureImmediate();
|
||||
this.applyImgTransform();
|
||||
}
|
||||
this.moveDisabled = true;
|
||||
clearTimeout(this.disabledTimer);
|
||||
this.disabledTimer = setTimeout(() => (this.moveDisabled = false), this.moveDisabledTime);
|
||||
|
||||
const p1 = event.targetTouches[0];
|
||||
const p2 = event.targetTouches[1];
|
||||
const touchDistance = Math.sqrt((p2.pageX - p1.pageX) ** 2 + (p2.pageY - p1.pageY) ** 2);
|
||||
|
||||
if (!this.lastTouchDistance) {
|
||||
this.lastTouchDistance = touchDistance;
|
||||
return;
|
||||
}
|
||||
let newScale = this.scale + (touchDistance - this.lastTouchDistance) / (this.$refs.imgex.width / 5);
|
||||
newScale = Math.max(this.minScale, Math.min(this.maxScale, newScale));
|
||||
if (newScale !== this.scale) {
|
||||
this.scale = newScale;
|
||||
}
|
||||
this.lastTouchDistance = touchDistance;
|
||||
this.setZoom();
|
||||
return;
|
||||
}
|
||||
if (event.targetTouches.length === 1 && this.scale === 1 && !this.pinchActive) {
|
||||
const touch = event.targetTouches[0];
|
||||
this.edgeDx = touch.pageX - this.edgeStartX;
|
||||
this.edgeDy = touch.pageY - this.edgeStartY;
|
||||
@@ -639,36 +679,15 @@ export default {
|
||||
this.applyEdgeVisuals();
|
||||
return;
|
||||
}
|
||||
if (this.lastX === null) {
|
||||
this.lastX = event.targetTouches[0].pageX;
|
||||
this.lastY = event.targetTouches[0].pageY;
|
||||
return;
|
||||
}
|
||||
let step = this.$refs.imgex.width / 5;
|
||||
if (event.targetTouches.length === 2) {
|
||||
this.moveDisabled = true;
|
||||
clearTimeout(this.disabledTimer);
|
||||
this.disabledTimer = setTimeout(
|
||||
() => (this.moveDisabled = false),
|
||||
this.moveDisabledTime
|
||||
);
|
||||
let p1 = event.targetTouches[0];
|
||||
let p2 = event.targetTouches[1];
|
||||
let touchDistance = Math.sqrt(
|
||||
Math.pow(p2.pageX - p1.pageX, 2) + Math.pow(p2.pageY - p1.pageY, 2)
|
||||
);
|
||||
if (!this.lastTouchDistance) {
|
||||
this.lastTouchDistance = touchDistance;
|
||||
if (event.targetTouches.length === 1 && this.scale > 1) {
|
||||
if (this.moveDisabled) return;
|
||||
if (this.lastX === null) {
|
||||
this.lastX = event.targetTouches[0].pageX;
|
||||
this.lastY = event.targetTouches[0].pageY;
|
||||
return;
|
||||
}
|
||||
this.scale += (touchDistance - this.lastTouchDistance) / step;
|
||||
this.lastTouchDistance = touchDistance;
|
||||
this.setZoom();
|
||||
} else if (event.targetTouches.length === 1 && this.scale > 1) {
|
||||
if (this.moveDisabled) return;
|
||||
let x = event.targetTouches[0].pageX - this.lastX;
|
||||
let y = event.targetTouches[0].pageY - this.lastY;
|
||||
if (Math.abs(x) >= step && Math.abs(y) >= step) return;
|
||||
const x = event.targetTouches[0].pageX - this.lastX;
|
||||
const y = event.targetTouches[0].pageY - this.lastY;
|
||||
this.lastX = event.targetTouches[0].pageX;
|
||||
this.lastY = event.targetTouches[0].pageY;
|
||||
this.doMove(x, y);
|
||||
@@ -696,6 +715,15 @@ export default {
|
||||
return +style.replace("px", "");
|
||||
},
|
||||
touchEnd(event) {
|
||||
if (this.pinchActive) {
|
||||
if (event.touches.length === 0) {
|
||||
this.pinchActive = false;
|
||||
this.resetEdgeGestureImmediate();
|
||||
this.applyImgTransform();
|
||||
}
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (this.scale === 1 && event.changedTouches.length > 0) {
|
||||
const t = event.changedTouches[0];
|
||||
this.edgeDx = t.pageX - this.edgeStartX;
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
:clickable="false"
|
||||
:forceFilesApi="!!browseSource"
|
||||
:showLimitedOptions="true"
|
||||
:inlinePin="true"
|
||||
:pinned="item.pinned"
|
||||
@click.prevent="(event) => handleItemClick(item, index, event)"
|
||||
@dblclick.prevent="(event) => handleItemDblClick(item, index, event)"
|
||||
/>
|
||||
@@ -56,6 +58,7 @@ import { url } from "@/utils";
|
||||
import { resourcesApi } from "@/api";
|
||||
import ListingItem from "@/components/files/ListingItem.vue";
|
||||
import LoadingSpinner from "@/components/LoadingSpinner.vue";
|
||||
import { sortedItems } from "@/utils/sort.js";
|
||||
|
||||
export default {
|
||||
name: "file-list",
|
||||
@@ -145,7 +148,7 @@ export default {
|
||||
},
|
||||
availableSources() {
|
||||
// Get all available sources from state.sources.info
|
||||
return state.sources && state.sources.info ? Object.keys(state.sources.info) : [state.req.source];
|
||||
return state.sources.info ? Object.keys(state.sources.info) : [state.req.source];
|
||||
},
|
||||
showSourceSelector() {
|
||||
if (this.hideDestinationSource) {
|
||||
@@ -225,7 +228,7 @@ export default {
|
||||
if (this.path !== "/" && this.showFolders) {
|
||||
this.items.push({
|
||||
name: "..",
|
||||
path: url.removeLastDir(this.path) + "/",
|
||||
path: `${url.removeLastDir(this.path)}/`,
|
||||
source: this.source,
|
||||
type: "directory",
|
||||
});
|
||||
@@ -277,7 +280,7 @@ export default {
|
||||
this.selectedSource = null;
|
||||
this.selectedType = null;
|
||||
// Fetch files for the new source
|
||||
this.withLoading(() => resourcesApi.fetchFiles(newSource, newPath).then(this.fillOptions));
|
||||
void this.withLoading(() => resourcesApi.fetchFiles(newSource, newPath).then(this.fillOptions));
|
||||
},
|
||||
resetToShare(newHash) {
|
||||
// Reset to the share root
|
||||
@@ -288,7 +291,7 @@ export default {
|
||||
this.selectedSource = null;
|
||||
this.selectedType = null;
|
||||
// Fetch files for the share
|
||||
this.withLoading(() => resourcesApi.fetchFilesPublic("/", newHash).then(this.fillOptions));
|
||||
void this.withLoading(() => resourcesApi.fetchFilesPublic("/", newHash).then(this.fillOptions));
|
||||
},
|
||||
fillOptions(req) {
|
||||
// Sets the current path and resets the current items.
|
||||
@@ -305,31 +308,36 @@ export default {
|
||||
isValid: !this.requireFileSelection, // Folder is only valid if file is not required
|
||||
});
|
||||
|
||||
// If the path isn't the root path,
|
||||
// show a button to navigate to the previous
|
||||
// directory (unless we are only displaying files).
|
||||
if (this.path !== "/" && this.showFolders) {
|
||||
this.items.push({
|
||||
name: "..",
|
||||
path: url.removeLastDir(this.path) + "/",
|
||||
source: this.source,
|
||||
type: "directory",
|
||||
});
|
||||
const entries = [];
|
||||
if (req.items && Array.isArray(req.items)) {
|
||||
for (const item of req.items) {
|
||||
if (!this.showFolders && item.type === "directory") continue;
|
||||
if (!this.showFiles && item.type !== "directory") continue;
|
||||
if (item.type !== "directory" && !this.isFileTypeAllowed(item.type)) continue;
|
||||
entries.push({
|
||||
name: item.name,
|
||||
path: item.path,
|
||||
source: item.source || req.source,
|
||||
type: item.type,
|
||||
pinned: !!item.pinned,
|
||||
originalItem: item,
|
||||
});
|
||||
}
|
||||
const sorting = getters.sorting();
|
||||
const dirs = entries.filter((item) => item.type === "directory");
|
||||
const files = entries.filter((item) => item.type !== "directory");
|
||||
this.items = [
|
||||
...sortedItems(dirs, sorting.by, sorting.asc),
|
||||
...sortedItems(files, sorting.by, sorting.asc),
|
||||
];
|
||||
}
|
||||
|
||||
// If this folder has no items or items is not an array, finish here.
|
||||
if (!req.items || !Array.isArray(req.items)) return;
|
||||
for (let item of req.items) {
|
||||
if (!this.showFolders && item.type === "directory") continue;
|
||||
if (!this.showFiles && item.type !== "directory") continue;
|
||||
// Filter by file type if specified (only for files, not directories)
|
||||
if (item.type !== "directory" && !this.isFileTypeAllowed(item.type)) continue;
|
||||
this.items.push({
|
||||
name: item.name,
|
||||
path: item.path,
|
||||
source: item.source || req.source,
|
||||
type: item.type, // Store type for file selection
|
||||
originalItem: item, // Store original item for Icon component
|
||||
if (this.path !== "/" && this.showFolders) {
|
||||
this.items.unshift({
|
||||
name: "..",
|
||||
path: `${url.removeLastDir(this.path)}/`,
|
||||
source: this.source,
|
||||
type: "directory",
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -337,9 +345,9 @@ export default {
|
||||
// Retrieves the URL of the directory the user
|
||||
// just clicked in and fill the options with its
|
||||
// content.
|
||||
let path = event.currentTarget.dataset.path;
|
||||
let clickedItem = this.items.find(item => item.path === path);
|
||||
let sourceToUse = clickedItem ? clickedItem.source : this.source;
|
||||
const path = event.currentTarget.dataset.path;
|
||||
const clickedItem = this.items.find(item => item.path === path);
|
||||
const sourceToUse = clickedItem ? clickedItem.source : this.source;
|
||||
|
||||
// If showFiles and showFolders is true, and clicked item is a file (not a directory), select it directly
|
||||
if (this.showFiles && clickedItem && clickedItem.type !== "directory") {
|
||||
@@ -365,19 +373,19 @@ export default {
|
||||
if (this.browseSource) {
|
||||
// Explicitly browsing a source - use files API
|
||||
this.source = sourceToUse;
|
||||
this.withLoading(() => resourcesApi.fetchFiles(sourceToUse, path).then(this.fillOptions));
|
||||
void this.withLoading(() => resourcesApi.fetchFiles(sourceToUse, path).then(this.fillOptions));
|
||||
} else if (this.browseShare || getters.isShare()) {
|
||||
// Browsing a share - use public API
|
||||
const hashToUse = this.browseShare || state.shareInfo?.hash;
|
||||
this.withLoading(() => resourcesApi.fetchFilesPublic(path, hashToUse).then(this.fillOptions));
|
||||
void this.withLoading(() => resourcesApi.fetchFilesPublic(path, hashToUse).then(this.fillOptions));
|
||||
} else {
|
||||
this.source = sourceToUse;
|
||||
this.withLoading(() => resourcesApi.fetchFiles(sourceToUse, path).then(this.fillOptions));
|
||||
void this.withLoading(() => resourcesApi.fetchFiles(sourceToUse, path).then(this.fillOptions));
|
||||
}
|
||||
|
||||
},
|
||||
touchstart(event) {
|
||||
let url = event.currentTarget.dataset.path;
|
||||
const url = event.currentTarget.dataset.path;
|
||||
|
||||
// In 300 milliseconds, we shall reset the count.
|
||||
setTimeout(() => {
|
||||
@@ -438,7 +446,7 @@ export default {
|
||||
this.next(syntheticEvent);
|
||||
},
|
||||
select: function (event) {
|
||||
let path = event.currentTarget.dataset.path;
|
||||
const path = event.currentTarget.dataset.path;
|
||||
// If the element is already selected, unselect it.
|
||||
if (this.selected === path) {
|
||||
this.selected = null;
|
||||
@@ -454,7 +462,7 @@ export default {
|
||||
}
|
||||
// Otherwise select the element.
|
||||
this.selected = path;
|
||||
let clickedItem = this.items.find(item => item.path === path);
|
||||
const clickedItem = this.items.find(item => item.path === path);
|
||||
this.selectedSource = clickedItem ? clickedItem.source : this.source;
|
||||
this.selectedType = clickedItem ? clickedItem.type : null;
|
||||
const isFile = clickedItem && clickedItem.type !== "directory";
|
||||
@@ -487,7 +495,7 @@ export default {
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
let p = path == null || path === "" ? "/" : String(path);
|
||||
let p = path === null || path === "" ? "/" : String(path);
|
||||
if (!p.startsWith("/")) {
|
||||
p = `/${p}`;
|
||||
}
|
||||
@@ -502,13 +510,9 @@ export default {
|
||||
this.selectedType = null;
|
||||
if (this.browseShare || getters.isShare()) {
|
||||
const hashToUse = this.browseShare || state.shareInfo?.hash;
|
||||
this.withLoading(() =>
|
||||
resourcesApi.fetchFilesPublic(p, hashToUse).then(this.fillOptions)
|
||||
);
|
||||
void this.withLoading(() => resourcesApi.fetchFilesPublic(p, hashToUse).then(this.fillOptions));
|
||||
} else {
|
||||
this.withLoading(() =>
|
||||
resourcesApi.fetchFiles(source, p).then(this.fillOptions)
|
||||
);
|
||||
void this.withLoading(() => resourcesApi.fetchFiles(source, p).then(this.fillOptions));
|
||||
}
|
||||
},
|
||||
fillFromList() {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<i class="material-symbols">error</i>
|
||||
<span>{{ $t("prompts.error") }}</span>
|
||||
</div>
|
||||
<ul v-if="effectiveNodes && effectiveNodes.length" class="tree-list">
|
||||
<ul v-if="effectiveNodes?.length" class="tree-list">
|
||||
<li v-for="node in effectiveNodes" :key="node.path" class="tree-item">
|
||||
<div
|
||||
class="tree-node"
|
||||
@@ -81,7 +81,9 @@ import LoadingSpinner from '@/components/LoadingSpinner.vue';
|
||||
import { state, getters, mutations } from '@/store';
|
||||
import { eventBus } from '@/store/eventBus';
|
||||
import { goToItem, joinPath } from '@/utils/url';
|
||||
import { goToItemNotificationButton } from '@/utils/notificationActions';
|
||||
import { notify } from '@/notify';
|
||||
import { getObjectProperty } from '@/utils/object.js';
|
||||
|
||||
export default {
|
||||
name: 'FileTree',
|
||||
@@ -136,7 +138,7 @@ export default {
|
||||
return this.isRootInstance ? this.rootNodes : this.nodes;
|
||||
},
|
||||
canModify() {
|
||||
return getters.permissions()?.modify;
|
||||
return getters.permissions().modify;
|
||||
},
|
||||
showFiles() {
|
||||
// Defaults to true
|
||||
@@ -204,7 +206,7 @@ export default {
|
||||
},
|
||||
beforeUnmount() {
|
||||
// Clear all expand timeouts
|
||||
this.expandTimeouts.forEach(timeout => clearTimeout(timeout));
|
||||
this.expandTimeouts.forEach(timeout => { clearTimeout(timeout); });
|
||||
this.expandTimeouts.clear();
|
||||
if (this.unwatchReload) {
|
||||
this.unwatchReload();
|
||||
@@ -237,7 +239,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async fetchItems(path) {
|
||||
let items = [];
|
||||
let items;
|
||||
if (this.isShare) {
|
||||
const res = await resourcesApi.fetchFilesPublic(path, this.shareHash, state.shareInfo?.password, false, false, true);
|
||||
items = res.items || [];
|
||||
@@ -315,7 +317,7 @@ export default {
|
||||
// don't navigate to current item if we're already viewing it
|
||||
if (this.isCurrentItem(node)) {
|
||||
if (node.isDir) {
|
||||
this.toggleExpand(node, false); // If the item is a folder, just expand/collapse instead of navigate again
|
||||
void this.toggleExpand(node, false); // If the item is a folder, just expand/collapse instead of navigate again
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -379,8 +381,7 @@ export default {
|
||||
|
||||
let currentLevel = this.isRootInstance ? this.rootNodes : this.nodes;
|
||||
|
||||
for (let i = 0; i < pathParts.length; i++) {
|
||||
const part = pathParts[i];
|
||||
for (const part of pathParts) {
|
||||
const node = currentLevel.find(n => n.name === part && n.isDir);
|
||||
if (!node) break;
|
||||
|
||||
@@ -467,7 +468,7 @@ export default {
|
||||
}
|
||||
// Set a new timeout
|
||||
const timeout = setTimeout(() => {
|
||||
this.toggleExpand(node, true); // expand without navigating
|
||||
void this.toggleExpand(node, true); // expand without navigating
|
||||
this.expandTimeouts.delete(node);
|
||||
}, 800); // 800ms delay (we need to hover that time to auto expand when dragging a item)
|
||||
this.expandTimeouts.set(node, timeout);
|
||||
@@ -486,7 +487,7 @@ export default {
|
||||
this.rootNodes.forEach(clearNode);
|
||||
|
||||
// Clear all pending expand timeouts
|
||||
this.expandTimeouts.forEach(timeout => clearTimeout(timeout));
|
||||
this.expandTimeouts.forEach(timeout => { clearTimeout(timeout); });
|
||||
this.expandTimeouts.clear();
|
||||
},
|
||||
|
||||
@@ -529,12 +530,12 @@ export default {
|
||||
// Build list of items to move
|
||||
const items = [];
|
||||
for (const index of selectedIndices) {
|
||||
const item = state.req.items[index];
|
||||
const item = getObjectProperty(state.req?.items, index);
|
||||
if (!item) continue;
|
||||
|
||||
// Prevent dropping onto itself or into its own subdirectory
|
||||
if (item.path === node.path) continue; // cannot drop onto itself
|
||||
if (node.path.startsWith(item.path + '/')) continue; // cannot drop into its own subdirectory
|
||||
if (node.path.startsWith(`${item.path}/`)) continue; // cannot drop into its own subdirectory
|
||||
|
||||
items.push({
|
||||
from: item.path,
|
||||
@@ -587,20 +588,16 @@ export default {
|
||||
} else {
|
||||
await resourcesApi.moveCopy(items, 'move', overwrite, rename);
|
||||
}
|
||||
const buttonAction = () => {
|
||||
if (this.isShare) {
|
||||
goToItem(this.shareHash, node.path, {}, false, true);
|
||||
} else {
|
||||
goToItem(this.currentSource, node.path, {});
|
||||
}
|
||||
};
|
||||
const buttonProps = {
|
||||
icon: 'folder',
|
||||
buttons: [{
|
||||
label: this.$t('buttons.goToItem'),
|
||||
primary: true,
|
||||
action: buttonAction,
|
||||
}]
|
||||
buttons: [
|
||||
goToItemNotificationButton(
|
||||
this.$t('buttons.goToItem'),
|
||||
this.isShare ? this.shareHash : this.currentSource,
|
||||
node.path,
|
||||
this.isShare
|
||||
),
|
||||
],
|
||||
};
|
||||
notify.showSuccess(this.$t('prompts.moveSuccess'), buttonProps);
|
||||
mutations.closeTopPrompt();
|
||||
@@ -657,7 +654,7 @@ export default {
|
||||
|
||||
// Compare node to each candidate (usually only one, but safe to loop)
|
||||
return candidates.some(selected => {
|
||||
if (!selected || !selected.path) return false;
|
||||
if (!selected.path) return false;
|
||||
if (this.isShare) {
|
||||
return selected.path === node.path;
|
||||
} else {
|
||||
|
||||
@@ -29,16 +29,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchPreviewImage } from "@/api/resources";
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import { getTypeInfo } from "@/utils/mimetype";
|
||||
import { getObjectProperty } from '@/utils/object.js';
|
||||
import { mutations, state, getters } from "@/store";
|
||||
import { setImageLoaded } from "@/utils/imageCache";
|
||||
import ThreeJs from "@/views/files/ThreeJs.vue";
|
||||
|
||||
// NEW: Define placeholder and error image URLs for easy configuration
|
||||
const PLACEHOLDER_URL = globalVars.baseURL + "public/static/img/placeholder.png"; // A generic loading placeholder
|
||||
const ERROR_URL = globalVars.baseURL + "public/static/img/placeholder.png";
|
||||
|
||||
export default {
|
||||
name: "Icon",
|
||||
components: {
|
||||
@@ -99,15 +97,24 @@ export default {
|
||||
classes: "",
|
||||
svgPath: "",
|
||||
previewTimeouts: [],
|
||||
previewAbortController: null,
|
||||
preloadAbortControllers: [],
|
||||
imageBlobUrl: null,
|
||||
// UPDATED: Manage image state directly
|
||||
imageState: "loading", // Can be 'loading', 'loaded', or 'error'
|
||||
imageTargetSrc: "", // This is now a data property
|
||||
imageTargetSrc: "", // API URL being loaded
|
||||
currentThumbnail: "", // Add currentThumbnail to data
|
||||
color: "", // Add color to data
|
||||
threeJsError: false, // Track if 3D preview failed
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
placeholderUrl() {
|
||||
return `${globalVars.baseURL}public/static/img/placeholder.png`;
|
||||
},
|
||||
errorUrl() {
|
||||
return `${globalVars.baseURL}public/static/img/placeholder.png`;
|
||||
},
|
||||
isFile() {
|
||||
return this.mimetype !== "directory";
|
||||
},
|
||||
@@ -115,7 +122,7 @@ export default {
|
||||
if (state.shareInfo?.disableThumbnails) {
|
||||
return false;
|
||||
}
|
||||
if (this.thumbnailUrl == "") {
|
||||
if (this.thumbnailUrl === "") {
|
||||
return false;
|
||||
}
|
||||
if (!this.hasPreview) {
|
||||
@@ -138,7 +145,7 @@ export default {
|
||||
if ((simpleType === "document" || simpleType === "text") && !getters.previewPerms().office) {
|
||||
return false;
|
||||
}
|
||||
if (!getters.previewPerms().folder && this.mimetype == "directory") {
|
||||
if (!getters.previewPerms().folder && this.mimetype === "directory") {
|
||||
return false;
|
||||
}
|
||||
// 3D models - show preview thumbnails (if backend provides them)
|
||||
@@ -148,20 +155,18 @@ export default {
|
||||
return this.imageState !== 'error' && !this.disablePreviewExt && !this.officeFileDisabled;
|
||||
},
|
||||
disablePreviewExt() {
|
||||
const ext = "." + (this.filename.split(".").pop() || "").toLowerCase(); // Ensure lowercase and dot
|
||||
// @ts-ignore
|
||||
const ext = `.${(this.filename.split(".").pop() || "").toLowerCase()}`; // Ensure lowercase and dot
|
||||
return state.user?.disablePreviewExt?.includes(ext);
|
||||
},
|
||||
officeFileDisabled() {
|
||||
const ext = "." + (this.filename.split(".").pop() || "").toLowerCase(); // Ensure lowercase and dot
|
||||
// @ts-ignore
|
||||
const ext = `.${(this.filename.split(".").pop() || "").toLowerCase()}`; // Ensure lowercase and dot
|
||||
return state.user?.disablePreviewExt?.includes(ext);
|
||||
},
|
||||
pdfConvertable() {
|
||||
if (!globalVars.muPdfAvailable) {
|
||||
return false; // If muPDF is not available
|
||||
}
|
||||
const ext = "." + (this.filename.split(".").pop() || "").toLowerCase(); // Ensure lowercase and dot
|
||||
const ext = `.${(this.filename.split(".").pop() || "").toLowerCase()}`; // Ensure lowercase and dot
|
||||
const pdfConvertCompatibleFileExtensions = {
|
||||
".pdf": true,
|
||||
".xps": true,
|
||||
@@ -183,17 +188,23 @@ export default {
|
||||
// NEW: A single computed property to determine the final image src
|
||||
imageDisplaySrc() {
|
||||
if (this.imageState === "error") {
|
||||
return ERROR_URL;
|
||||
return this.errorUrl;
|
||||
}
|
||||
// Show placeholder only for the initial load, not during hover animations
|
||||
if (this.imageState === "loading") {
|
||||
return PLACEHOLDER_URL;
|
||||
return this.placeholderUrl;
|
||||
}
|
||||
return this.imageTargetSrc;
|
||||
return this.imageBlobUrl || this.placeholderUrl;
|
||||
},
|
||||
showLargeIcon() {
|
||||
return getters.viewMode() === "gallery";
|
||||
},
|
||||
popupPreviewUrl() {
|
||||
if (!this.thumbnailUrl) {
|
||||
return "";
|
||||
}
|
||||
return `${this.thumbnailUrl}&size=xlarge`;
|
||||
},
|
||||
showLarger() {
|
||||
return getters.viewMode() === "gallery" || getters.viewMode() === "normal";
|
||||
},
|
||||
@@ -215,7 +226,7 @@ export default {
|
||||
},
|
||||
shouldUse3DPreview() {
|
||||
// Check if we should use 3D preview instead of regular icon
|
||||
if (!this.isFile || !this.size || !this.path) return false;
|
||||
if (this.mimetype === "directory" || !this.size || !this.path) return false;
|
||||
if (!getters.previewPerms().models) return false;
|
||||
|
||||
const MAX_SIZE = 250 * 1024; // 250KB in bytes
|
||||
@@ -229,13 +240,35 @@ export default {
|
||||
// Also includes view mode to handle view changes
|
||||
return `${state.user?.gallerySize || 1}-${getters.viewMode()}`;
|
||||
},
|
||||
routePath() {
|
||||
return state.route.path ?? "";
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handle3DError() {
|
||||
// When 3D preview fails, fall back to material icon
|
||||
this.threeJsError = true;
|
||||
},
|
||||
// NEW: Centralized method to load any image and handle its state
|
||||
cancelPreloadRequests() {
|
||||
this.previewTimeouts.forEach(clearTimeout);
|
||||
this.previewTimeouts = [];
|
||||
for (const controller of this.preloadAbortControllers) {
|
||||
controller.abort();
|
||||
}
|
||||
this.preloadAbortControllers = [];
|
||||
},
|
||||
cancelActivePreviews() {
|
||||
this.cancelPreloadRequests();
|
||||
if (this.previewAbortController) {
|
||||
this.previewAbortController.abort();
|
||||
this.previewAbortController = null;
|
||||
}
|
||||
if (this.imageBlobUrl) {
|
||||
URL.revokeObjectURL(this.imageBlobUrl);
|
||||
this.imageBlobUrl = null;
|
||||
}
|
||||
},
|
||||
// Load preview via fetch so requests can be aborted on navigation
|
||||
/**
|
||||
* @param {string} url
|
||||
*/
|
||||
@@ -245,33 +278,42 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancelActivePreviews();
|
||||
this.imageState = "loading";
|
||||
const targetImage = new Image();
|
||||
|
||||
targetImage.onload = () => {
|
||||
// Prevent race conditions: only update if this is the image we still want.
|
||||
if (this.imageTargetSrc === url) {
|
||||
this.imageState = "loaded";
|
||||
// Mark this image as loaded in our cache tracker
|
||||
if (this.path) {
|
||||
// For shares, use shareInfo.hash as the source; otherwise use this.source or state.req.source
|
||||
const source = getters.isShare() ? state.shareInfo?.hash : (this.source || state.req.source);
|
||||
const size = this.showLargeIcon ? 'large' : 'small';
|
||||
// Use file's modified date if available, otherwise fall back to state.req.modified
|
||||
const modified = this.modified || state.req.modified;
|
||||
setImageLoaded(source, this.path, size, modified, url);
|
||||
const controller = new AbortController();
|
||||
this.previewAbortController = controller;
|
||||
const loadUrl = url;
|
||||
|
||||
fetchPreviewImage(loadUrl, controller.signal)
|
||||
.then((blobUrl) => {
|
||||
if (this.previewAbortController !== controller) {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
targetImage.onerror = () => {
|
||||
// Prevent race conditions: only show an error if this is the image that failed.
|
||||
if (this.imageTargetSrc === url) {
|
||||
this.imageState = "error";
|
||||
}
|
||||
};
|
||||
|
||||
targetImage.src = url;
|
||||
if (this.imageTargetSrc !== loadUrl) {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
return;
|
||||
}
|
||||
this.imageBlobUrl = blobUrl;
|
||||
this.imageState = "loaded";
|
||||
this.previewAbortController = null;
|
||||
if (this.path) {
|
||||
const source = getters.isShare() ? state.shareInfo?.hash : (this.source || state.req.source);
|
||||
const size = this.showLargeIcon ? "large" : "small";
|
||||
const modified = this.modified || state.req.modified;
|
||||
setImageLoaded(source, this.path, size, modified, loadUrl);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err?.name === "AbortError") {
|
||||
return;
|
||||
}
|
||||
if (this.imageTargetSrc === loadUrl && this.previewAbortController === controller) {
|
||||
this.imageState = "error";
|
||||
this.previewAbortController = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleMouseEnter() {
|
||||
if (!getters.previewPerms().popup || !this.path) {
|
||||
@@ -297,11 +339,10 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// Image (and other preview types): use thumbnail URL
|
||||
const imageUrl = this.thumbnailUrl + "&size=large";
|
||||
// Image (and other preview types): popup always uses xlarge preview
|
||||
const imageUrl = this.popupPreviewUrl;
|
||||
if (this.imageState === "loaded") {
|
||||
mutations.setPreviewSource(imageUrl);
|
||||
state.popupPreviewSourceInfo = { source, path: this.path, size: "large", url: imageUrl, modified };
|
||||
state.popupPreviewSourceInfo = { source, path: this.path, size: "xlarge", url: imageUrl, modified };
|
||||
}
|
||||
// Motion preview: video (atPercentage) or folder (cycle next previewable image)
|
||||
const useVideoMotion = getters.previewPerms().motionVideoPreview && this.hasMotion;
|
||||
@@ -312,9 +353,9 @@ export default {
|
||||
|
||||
const sequence = [
|
||||
imageUrl,
|
||||
imageUrl + "&atPercentage=25",
|
||||
imageUrl + "&atPercentage=50",
|
||||
imageUrl + "&atPercentage=75",
|
||||
`${imageUrl}&atPercentage=25`,
|
||||
`${imageUrl}&atPercentage=50`,
|
||||
`${imageUrl}&atPercentage=75`,
|
||||
];
|
||||
let index = 0;
|
||||
|
||||
@@ -326,38 +367,37 @@ export default {
|
||||
}
|
||||
// Set the thumbnail or popup preview
|
||||
if (getters.previewPerms().popup) {
|
||||
mutations.setPreviewSource(sequence[index]);
|
||||
mutations.setPreviewSource(getObjectProperty(sequence, index));
|
||||
} else {
|
||||
this.currentThumbnail = sequence[index];
|
||||
this.currentThumbnail = getObjectProperty(sequence, index);
|
||||
}
|
||||
|
||||
// Preload the next image
|
||||
// Preload the next frame (cancellable fetch warms HTTP cache)
|
||||
const nextIndex = (index + 1) % sequence.length;
|
||||
const preloadImg = new Image();
|
||||
preloadImg.onload = () => {
|
||||
// Track that this image was loaded (motion preview frames use the same path)
|
||||
if (this.path) {
|
||||
// For shares, use shareInfo.hash as the source; otherwise use this.source or state.req.source
|
||||
const source = getters.isShare() ? state.shareInfo?.hash : (this.source || state.req.source);
|
||||
const frameUrl = sequence[nextIndex];
|
||||
// Use file's modified date if available, otherwise fall back to state.req.modified
|
||||
const modified = this.modified || state.req.modified;
|
||||
setImageLoaded(source, this.path, 'large', modified, frameUrl);
|
||||
}
|
||||
};
|
||||
preloadImg.src = sequence[nextIndex];
|
||||
const frameUrl = sequence.at(nextIndex);
|
||||
if (!frameUrl) return;
|
||||
const preloadController = new AbortController();
|
||||
this.preloadAbortControllers.push(preloadController);
|
||||
fetchPreviewImage(frameUrl, preloadController.signal)
|
||||
.then((blobUrl) => {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
if (this.path) {
|
||||
const source = getters.isShare() ? state.shareInfo?.hash : (this.source || state.req.source);
|
||||
const modified = this.modified || state.req.modified;
|
||||
setImageLoaded(source, this.path, "xlarge", modified, frameUrl);
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
// Schedule next update
|
||||
index = nextIndex;
|
||||
const timeoutId = setTimeout(updateThumbnail, 750);
|
||||
// @ts-ignore
|
||||
this.previewTimeouts.push(timeoutId);
|
||||
};
|
||||
updateThumbnail();
|
||||
},
|
||||
handleMouseLeave() {
|
||||
this.previewTimeouts.forEach(clearTimeout);
|
||||
this.previewTimeouts = [];
|
||||
this.cancelPreloadRequests();
|
||||
mutations.setPreviewSource("");
|
||||
// Clear popup preview source info when mouse leaves
|
||||
state.popupPreviewSourceInfo = null;
|
||||
@@ -368,11 +408,11 @@ export default {
|
||||
return getTypeInfo(this.mimetype);
|
||||
},
|
||||
updateImageTargetSrc() {
|
||||
let newSrc = this.thumbnailUrl || PLACEHOLDER_URL;
|
||||
let newSrc = this.thumbnailUrl || this.placeholderUrl;
|
||||
// If we need large thumbnails and have a thumbnail URL, append &size=large
|
||||
// Otherwise use the URL as-is (defaults to small)
|
||||
if (this.thumbnailUrl && this.showLargeIcon) {
|
||||
newSrc = this.thumbnailUrl + "&size=large";
|
||||
newSrc = `${this.thumbnailUrl}&size=large`;
|
||||
}
|
||||
|
||||
if (this.imageTargetSrc !== newSrc) {
|
||||
@@ -381,6 +421,10 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
routePath() {
|
||||
this.cancelActivePreviews();
|
||||
this.imageState = "loading";
|
||||
},
|
||||
thumbnailUrl() {
|
||||
this.updateImageTargetSrc();
|
||||
},
|
||||
@@ -422,17 +466,13 @@ export default {
|
||||
mounted() {
|
||||
const result = this.getIconForType();
|
||||
this.classes = result.classes || "material-symbols";
|
||||
// @ts-ignore
|
||||
this.color = result.color || "lightgray";
|
||||
this.materialSymbol = result.materialSymbol || "";
|
||||
// @ts-ignore
|
||||
this.svgPath = result.svgPath || "";
|
||||
this.updateImageTargetSrc();
|
||||
},
|
||||
beforeUnmount() {
|
||||
// Clean up any pending animation timeouts
|
||||
this.previewTimeouts.forEach(clearTimeout);
|
||||
this.previewTimeouts = [];
|
||||
this.cancelActivePreviews();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
];
|
||||
},
|
||||
rows() {
|
||||
return buildIndexInfoRows(this.info, this.$t, state.user.locale);
|
||||
return buildIndexInfoRows(this.info, this.$t, state.user?.locale);
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -60,14 +60,14 @@ export function getStatusLabel(status, $t) {
|
||||
}
|
||||
|
||||
export function getHumanReadableTime(lastIndex, locale) {
|
||||
if (isNaN(Number(lastIndex))) return "";
|
||||
let val = Number(lastIndex);
|
||||
if (Number.isNaN(Number(lastIndex))) return "";
|
||||
const val = Number(lastIndex);
|
||||
if (val === 0) return "now";
|
||||
return fromNow(val, locale);
|
||||
}
|
||||
|
||||
export function formatDuration(seconds) {
|
||||
if (isNaN(Number(seconds))) return '';
|
||||
if (Number.isNaN(Number(seconds))) return '';
|
||||
return Number(seconds);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,15 +117,12 @@ export default {
|
||||
return "arrow_upward";
|
||||
},
|
||||
quickDownloadEnabled() {
|
||||
// @ts-ignore
|
||||
if (state.isMobile) {
|
||||
return false
|
||||
}
|
||||
if (getters.isShare()) {
|
||||
// @ts-ignore
|
||||
return state.shareInfo?.quickDownload;
|
||||
}
|
||||
// @ts-ignore
|
||||
return state.user?.quickDownload && !this.galleryView;
|
||||
},
|
||||
},
|
||||
@@ -159,7 +156,6 @@ export default {
|
||||
box-sizing: border-box;
|
||||
border-top-left-radius: 1em;
|
||||
border-top-right-radius: 1em;
|
||||
border: unset;
|
||||
margin-bottom: 0 !important;
|
||||
justify-content: space-between;
|
||||
}
|
||||
@@ -191,15 +187,21 @@ span {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.desktop-view .modified{
|
||||
min-width: 15%;
|
||||
flex: 0;
|
||||
}
|
||||
|
||||
.desktop-view .size,
|
||||
.desktop-view .duration {
|
||||
min-width: 10%;
|
||||
flex: 0;
|
||||
width: 12%;
|
||||
min-width: 80px;
|
||||
flex: 0 0 auto;
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.desktop-view .modified {
|
||||
width: 18%;
|
||||
min-width: 110px;
|
||||
flex: 0 0 auto;
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.size,
|
||||
@@ -210,7 +212,6 @@ span {
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
|
||||
i {
|
||||
font-size: 1.5em;
|
||||
vertical-align: middle;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
class="listing-item clickable no-select"
|
||||
:class="{
|
||||
activebutton: isSelected,
|
||||
'pinned-item': isPinned,
|
||||
hiddenFile: isHiddenNotSelected && this && !this.isDraggedOver,
|
||||
'half-selected': isDraggedOver,
|
||||
'drag-hover': isDraggedOver,
|
||||
@@ -47,37 +48,43 @@
|
||||
</div>
|
||||
|
||||
<div class="text">
|
||||
<p class="name">{{ displayName }}</p>
|
||||
<p
|
||||
class="size"
|
||||
:data-order="humanSize"
|
||||
>
|
||||
{{ humanSize }}
|
||||
<!-- For list/compact pin inside .name (inline), or if inlinePin is true (like on FileList) -->
|
||||
<p v-if="isListMode || inlinePin" class="name">
|
||||
<span>{{ displayName }}</span>
|
||||
<i v-if="isPinned" class="material-symbols pinned-indicator">push_pin</i>
|
||||
</p>
|
||||
<p class="modified">
|
||||
<time :datetime="modified">{{ formattedTime }}</time>
|
||||
<!-- For other views pin is separate -->
|
||||
<p v-else class="name">
|
||||
<span>{{ displayName }}</span>
|
||||
</p>
|
||||
<p class="size" :data-order="humanSize">{{ humanSize }}</p>
|
||||
<p class="modified"><time :datetime="modified">{{ formattedTime }}</time></p>
|
||||
<p v-if="hasDuration" class="duration">{{ formattedDuration }}</p>
|
||||
</div>
|
||||
<Icon
|
||||
@click.stop="downloadFile"
|
||||
v-if="quickDownloadEnabled"
|
||||
:filename="name"
|
||||
:hasPreview="hasPreview"
|
||||
mimetype="file_download"
|
||||
class="download-icon"
|
||||
role="button"
|
||||
aria-label="Download"
|
||||
tabindex="0"
|
||||
:clickable=true
|
||||
:isShared="isShared"
|
||||
/>
|
||||
<div v-if="isPinned && !isListMode && !inlinePin" class="pin-icon-wrapper">
|
||||
<i class="material-symbols pinned-indicator">push_pin</i>
|
||||
</div>
|
||||
|
||||
<Icon
|
||||
@click.stop="downloadFile"
|
||||
v-if="quickDownloadEnabled"
|
||||
:filename="name"
|
||||
:hasPreview="hasPreview"
|
||||
mimetype="file_download"
|
||||
class="download-icon"
|
||||
role="button"
|
||||
aria-label="Download"
|
||||
tabindex="0"
|
||||
:clickable="true"
|
||||
:isShared="isShared"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
v-else
|
||||
class="listing-item no-select clickable"
|
||||
:class="{
|
||||
activebutton: isSelected,
|
||||
'pinned-item': isPinned,
|
||||
hiddenFile: isHiddenNotSelected && this && !this.isDraggedOver,
|
||||
'half-selected': isDraggedOver,
|
||||
'drag-hover': isDraggedOver,
|
||||
@@ -114,31 +121,34 @@
|
||||
</div>
|
||||
|
||||
<div class="text">
|
||||
<p class="name">{{ displayName }}</p>
|
||||
<p
|
||||
class="size"
|
||||
:data-order="humanSize"
|
||||
>
|
||||
{{ humanSize }}
|
||||
<p v-if="isListMode || inlinePin" class="name">
|
||||
<span>{{ displayName }}</span>
|
||||
<i v-if="isPinned" class="material-symbols pinned-indicator">push_pin</i>
|
||||
</p>
|
||||
<p class="modified">
|
||||
<time :datetime="modified">{{ formattedTime }}</time>
|
||||
<p v-else class="name">
|
||||
<span>{{ displayName }}</span>
|
||||
</p>
|
||||
<p class="size" :data-order="humanSize">{{ humanSize }}</p>
|
||||
<p class="modified"><time :datetime="modified">{{ formattedTime }}</time></p>
|
||||
<p v-if="hasDuration" class="duration">{{ formattedDuration }}</p>
|
||||
</div>
|
||||
<div v-if="isPinned && !isListMode && !inlinePin" class="pin-icon-wrapper">
|
||||
<i class="material-symbols pinned-indicator">push_pin</i>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { globalVars } from "@/utils/constants";
|
||||
import downloadFiles from "@/utils/download";
|
||||
|
||||
import { getHumanReadableFilesize } from "@/utils/filesizes";
|
||||
import { getObjectProperty } from '@/utils/object.js';
|
||||
import { resourcesApi } from "@/api";
|
||||
import * as upload from "@/utils/upload";
|
||||
import { state, getters, mutations } from "@/store"; // Import your custom store
|
||||
import { url } from "@/utils";
|
||||
import { notify } from "@/notify";
|
||||
import { goToItemNotificationButton } from "@/utils/notificationActions";
|
||||
import Icon from "@/components/files/Icon.vue";
|
||||
|
||||
export default {
|
||||
@@ -205,6 +215,14 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
inlinePin: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
pinned: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayName() {
|
||||
@@ -215,21 +233,15 @@ export default {
|
||||
return getters.viewMode() === "gallery";
|
||||
},
|
||||
quickDownloadEnabled() {
|
||||
// @ts-ignore
|
||||
if (getters.isShare()) {
|
||||
// @ts-ignore
|
||||
return state.shareInfo?.quickDownload && !this.galleryView;
|
||||
}
|
||||
// @ts-ignore
|
||||
return state.user?.quickDownload && !this.galleryView;
|
||||
},
|
||||
quickDownloadPlaceholder() {
|
||||
// @ts-ignore
|
||||
if (getters.isShare()) {
|
||||
// @ts-ignore
|
||||
return state.shareInfo?.quickDownload && !this.galleryView && this.isDir;
|
||||
}
|
||||
// @ts-ignore
|
||||
return state.user?.quickDownload && !this.galleryView && getters.viewMode() !== "icons" && getters.viewMode() !== "normal" && this.isDir;
|
||||
},
|
||||
isHiddenNotSelected() {
|
||||
@@ -248,7 +260,6 @@ export default {
|
||||
return state.selected;
|
||||
},
|
||||
isClicked() {
|
||||
// @ts-ignore
|
||||
if (state.user.singleClick || !this.allowedView) {
|
||||
return false;
|
||||
}
|
||||
@@ -262,26 +273,20 @@ export default {
|
||||
return state.selected.indexOf(this.index) !== -1;
|
||||
},
|
||||
isDraggable() {
|
||||
// @ts-ignore
|
||||
return this.readOnly == undefined && state.user.permissions?.modify || state.shareInfo.allowCreate;
|
||||
return this.readOnly === undefined && state.user.permissions?.modify || state.shareInfo.allowCreate;
|
||||
},
|
||||
canDrop() {
|
||||
if (!this.isDir) return false;
|
||||
if (this.readOnly === true) return false;
|
||||
|
||||
for (const i of this.selected) {
|
||||
if (
|
||||
// @ts-ignore
|
||||
state.req.items[i].path === this.path &&
|
||||
// @ts-ignore
|
||||
state.req.source === this.source
|
||||
) {
|
||||
const item = getObjectProperty(state.req.items, i);
|
||||
if (!item) continue;
|
||||
// Also check if we're trying to drop an item onto itself
|
||||
if (item.path === this.path && state.req.source === this.source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also check if we're trying to drop an item onto itself
|
||||
// @ts-ignore
|
||||
if (state.req.items[i].index === this.index) {
|
||||
if (item.index === this.index) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -297,7 +302,7 @@ export default {
|
||||
let previewPath;
|
||||
if (this.path) {
|
||||
previewPath = this.path;
|
||||
} else if (state?.req?.path && this.name) {
|
||||
} else if (state.req?.path && this.name) {
|
||||
previewPath = url.joinPath(state.req.path, this.name);
|
||||
} else {
|
||||
return "";
|
||||
@@ -305,15 +310,13 @@ export default {
|
||||
|
||||
// If forceFilesApi is true, always use authenticated files API
|
||||
if (this.forceFilesApi) {
|
||||
// @ts-ignore
|
||||
return resourcesApi.getPreviewURL(this.source || state?.req?.source, previewPath, this.modified);
|
||||
return resourcesApi.getPreviewURL(this.source || state.req?.source, previewPath, this.modified);
|
||||
}
|
||||
|
||||
if (getters.isShare()) {
|
||||
return resourcesApi.getPreviewURLPublic(previewPath);
|
||||
}
|
||||
// @ts-ignore
|
||||
return resourcesApi.getPreviewURL(this.source || state.req.source, previewPath, this.modified);
|
||||
return resourcesApi.getPreviewURL(this.source || state.req?.source, previewPath, this.modified);
|
||||
},
|
||||
isThumbsEnabled() {
|
||||
return globalVars.enableThumbs;
|
||||
@@ -321,9 +324,12 @@ export default {
|
||||
isClickable() {
|
||||
return this.clickable;
|
||||
},
|
||||
isPinned() {
|
||||
return this.pinned;
|
||||
},
|
||||
// Computed properties for display values - Vue caches these automatically!
|
||||
humanSize() {
|
||||
return this.type == "invalid_link"
|
||||
return this.type === "invalid_link"
|
||||
? "invalid link"
|
||||
: getHumanReadableFilesize(this.size);
|
||||
},
|
||||
@@ -331,7 +337,7 @@ export default {
|
||||
return getters.getTime(this.modified);
|
||||
},
|
||||
formattedDuration() {
|
||||
if (!this.metadata || !this.metadata.duration) {
|
||||
if (!this.metadata?.duration) {
|
||||
return "";
|
||||
}
|
||||
const seconds = this.metadata.duration;
|
||||
@@ -343,6 +349,10 @@ export default {
|
||||
}
|
||||
return `${minutes}:${secs.toString().padStart(2, '0')}`;
|
||||
},
|
||||
isListMode() {
|
||||
const mode = getters.viewMode();
|
||||
return mode === 'list' || mode === 'compact';
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// Set up IntersectionObserver for lazy-loading thumbnails
|
||||
@@ -381,7 +391,6 @@ export default {
|
||||
event.stopPropagation();
|
||||
if (this.updateGlobalState) {
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(this.index);
|
||||
downloadFiles(state.selected);
|
||||
} else {
|
||||
@@ -399,13 +408,11 @@ export default {
|
||||
const movementThreshold = 10; // Adjust as needed
|
||||
if (deltaX > movementThreshold || deltaY > movementThreshold) {
|
||||
this.isSwipe = true;
|
||||
// @ts-ignore
|
||||
this.cancelContext(); // Cancel long press if swipe is detected
|
||||
}
|
||||
},
|
||||
handleTouchEnd() {
|
||||
if (!state.isSafari) return;
|
||||
// @ts-ignore
|
||||
this.cancelContext(); // Clear timeout
|
||||
this.isSwipe = false; // Reset swipe state
|
||||
},
|
||||
@@ -423,9 +430,9 @@ export default {
|
||||
},
|
||||
getUrl() {
|
||||
if (this.hash) {
|
||||
return globalVars.baseURL + "public/share/" + this.hash + "/" + url.encodedPath(this.path);
|
||||
return `${globalVars.baseURL}public/share/${this.hash}/${url.encodedPath(this.path)}`;
|
||||
}
|
||||
return globalVars.baseURL + "files/" + encodeURIComponent(this.source) + url.encodedPath(this.path);
|
||||
return `${globalVars.baseURL}files/${encodeURIComponent(this.source)}${url.encodedPath(this.path)}`;
|
||||
},
|
||||
/** @param {MouseEvent} event */
|
||||
onRightClick(event) {
|
||||
@@ -434,7 +441,6 @@ export default {
|
||||
// If one or fewer items are selected, reset the selection
|
||||
if (!state.multiple && getters.selectedCount() < 2) {
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(this.index);
|
||||
}
|
||||
} else {
|
||||
@@ -451,7 +457,6 @@ export default {
|
||||
index: this.index,
|
||||
};
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(selectedItem);
|
||||
}
|
||||
|
||||
@@ -495,7 +500,6 @@ export default {
|
||||
if (this.updateGlobalState) {
|
||||
if (state.selected.indexOf(this.index) === -1) {
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(this.index);
|
||||
}
|
||||
} else {
|
||||
@@ -548,13 +552,15 @@ export default {
|
||||
event.stopPropagation();
|
||||
|
||||
let items = [];
|
||||
for (let i of state.selected) {
|
||||
for (const i of state.selected) {
|
||||
const item = getObjectProperty(state.req.items, i);
|
||||
if (!item) continue;
|
||||
items.push({
|
||||
from: state.req.items[i].path,
|
||||
fromSource: state.req.items[i].source,
|
||||
to: url.joinPath(this.path, state.req.items[i].name),
|
||||
from: item.path,
|
||||
fromSource: item.source,
|
||||
to: url.joinPath(this.path, item.name),
|
||||
toSource: this.source,
|
||||
name: state.req.items[i].name,
|
||||
name: item.name,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -571,7 +577,7 @@ export default {
|
||||
const destinationDir = this.path;
|
||||
|
||||
// If destination dir is the same as or contains the source path, skip
|
||||
if (fromPath === destinationDir || fromPath.startsWith(destinationDir + '/')) {
|
||||
if (fromPath === destinationDir || fromPath.startsWith(`${destinationDir}/`)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -583,7 +589,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
let checkAction = async () => {
|
||||
const checkAction = async () => {
|
||||
if (getters.isShare()) {
|
||||
return await resourcesApi.fetchFilesPublic(this.path, state.shareInfo.hash);
|
||||
} else {
|
||||
@@ -597,7 +603,7 @@ export default {
|
||||
* @param {boolean} overwrite
|
||||
* @param {boolean} rename
|
||||
*/
|
||||
let action = async (overwrite, rename) => {
|
||||
const action = async (overwrite, rename) => {
|
||||
// Show move prompt with operation in progress
|
||||
mutations.showPrompt({
|
||||
name: "move",
|
||||
@@ -613,18 +619,16 @@ export default {
|
||||
await resourcesApi.moveCopy(items, "move", overwrite, rename);
|
||||
}
|
||||
// Notification to move into the folder
|
||||
const buttonAction = () => {
|
||||
this.open();
|
||||
};
|
||||
const buttonProps = {
|
||||
icon: "folder",
|
||||
buttons: [
|
||||
{
|
||||
label: this.$t("buttons.goToItem"),
|
||||
primary: true,
|
||||
action: buttonAction
|
||||
}
|
||||
]
|
||||
goToItemNotificationButton(
|
||||
this.$t("buttons.goToItem"),
|
||||
this.source,
|
||||
this.path,
|
||||
getters.isShare()
|
||||
),
|
||||
],
|
||||
};
|
||||
notify.showSuccess(this.$t("prompts.moveSuccess"), buttonProps);
|
||||
// Close the prompt after successful operation and reload items for reflect the changes
|
||||
@@ -675,7 +679,6 @@ export default {
|
||||
if (state.multiple) {
|
||||
return;
|
||||
}
|
||||
// @ts-ignore
|
||||
this.contextTimeout = setTimeout(() => {
|
||||
if (!this.isSwipe) {
|
||||
// Only reset selection if this item is not already selected
|
||||
@@ -683,7 +686,6 @@ export default {
|
||||
if (!this.isSelected) {
|
||||
if (this.updateGlobalState) {
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(this.index);
|
||||
} else {
|
||||
this.$emit('select', { index: this.index, selected: true });
|
||||
@@ -703,7 +705,7 @@ export default {
|
||||
}
|
||||
|
||||
if (
|
||||
!state.user.singleClick &&
|
||||
!state.user?.singleClick &&
|
||||
getters.selectedCount() !== 0 &&
|
||||
event.button === 0
|
||||
) {
|
||||
@@ -736,7 +738,6 @@ export default {
|
||||
|
||||
for (; fi <= la; fi++) {
|
||||
if (this.selected.indexOf(fi) === -1) {
|
||||
// @ts-ignore
|
||||
mutations.addSelected(fi);
|
||||
}
|
||||
}
|
||||
@@ -759,7 +760,6 @@ export default {
|
||||
|
||||
if (this.selected.length > 1) {
|
||||
mutations.resetSelected();
|
||||
// @ts-ignore
|
||||
mutations.addSelected(this.index);
|
||||
mutations.setLastSelectedIndex(this.index);
|
||||
}
|
||||
@@ -767,7 +767,7 @@ export default {
|
||||
}
|
||||
|
||||
if (
|
||||
!state.user.singleClick &&
|
||||
!state.user?.singleClick &&
|
||||
!event.ctrlKey &&
|
||||
!event.metaKey &&
|
||||
!event.shiftKey &&
|
||||
@@ -802,14 +802,15 @@ export default {
|
||||
// Check if state.req.items exists and has the item at this index
|
||||
// This prevents errors when ListingItem is used outside of the main file listing (e.g., duplicate finder)
|
||||
let previousHistoryItem = null;
|
||||
if (state.req.items && state.req.items[this.index]) {
|
||||
const currentItem = getObjectProperty(state.req.items, this.index);
|
||||
if (currentItem) {
|
||||
previousHistoryItem = {
|
||||
name: state.req.items[this.index].name,
|
||||
name: currentItem.name,
|
||||
source: state.req.source,
|
||||
path: state.req.path,
|
||||
};
|
||||
}
|
||||
url.goToItem(this.source, this.path, previousHistoryItem || {}, false, getters.isShare());
|
||||
url.goToItem(this.source, this.path, previousHistoryItem, false, getters.isShare());
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -829,6 +830,10 @@ export default {
|
||||
-webkit-touch-callout: none; /* Disable the default long press preview */
|
||||
}
|
||||
|
||||
.listing-item.pinned-item {
|
||||
border-color: color-mix(in srgb, var(--primaryColor) 35%, transparent);
|
||||
}
|
||||
|
||||
/* Disable transitions and hide content for out-of-view items for better performance */
|
||||
.listing-item.out-of-view {
|
||||
transition: none !important;
|
||||
|
||||
Loaded 100 of 303 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user