add changes for read from 2 paths

This commit is contained in:
Erik Berlin 2024-02-11 10:07:16 +02:00
parent fe5ca74aa1
commit ccb9dbff03
28 changed files with 380 additions and 322 deletions

View File

@ -31,7 +31,6 @@ func addConfigFlags(flags *pflag.FlagSet) {
addServerFlags(flags)
addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup")
flags.Bool("create-user-dir", false, "generate user's home directory automatically")
flags.String("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type")

View File

@ -29,12 +29,11 @@ override the options.`,
authMethod, auther := getAuthentication(flags)
s := &settings.Settings{
Key: generateKey(),
Signup: mustGetBool(flags, "signup"),
CreateUserDir: mustGetBool(flags, "create-user-dir"),
Shell: convertCmdStrToCmdArray(mustGetString(flags, "shell")),
AuthMethod: authMethod,
Defaults: defaults,
Key: generateKey(),
Signup: mustGetBool(flags, "signup"),
Shell: convertCmdStrToCmdArray(mustGetString(flags, "shell")),
AuthMethod: authMethod,
Defaults: defaults,
Branding: settings.Branding{
Name: mustGetString(flags, "branding.name"),
DisableExternal: mustGetBool(flags, "branding.disableExternal"),

View File

@ -49,8 +49,6 @@ you want to change. Other options will remain unchanged.`,
hasAuth = true
case "shell":
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
case "create-user-dir":
set.CreateUserDir = mustGetBool(flags, flag.Name)
case "branding.name":
set.Branding.Name = mustGetString(flags, flag.Name)
case "branding.color":

View File

@ -60,6 +60,7 @@ func addServerFlags(flags *pflag.FlagSet) {
flags.StringP("cert", "t", "", "tls certificate")
flags.StringP("key", "k", "", "tls key")
flags.StringP("root", "r", ".", "root to prepend to relative paths")
flags.StringP("anotherPath", "R", "", "another path to use")
flags.String("socket", "", "socket to listen to (cannot be used with address, port, cert nor key flags)")
flags.Uint32("socket-perm", 0666, "unix socket file permissions") //nolint:gomnd
flags.StringP("baseurl", "b", "", "base url")
@ -205,6 +206,10 @@ func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server {
server.Root = val
}
if val, set := getParamB(flags, "anotherPath"); set {
server.AnotherPath = val
}
if val, set := getParamB(flags, "baseurl"); set {
server.BaseURL = val
}

View File

@ -16,15 +16,15 @@ import (
"path"
"path/filepath"
"strings"
"sync"
"time"
"github.com/spf13/afero"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/spf13/afero"
)
const PermFile = 0644
const PermFile = 0664
const PermDir = 0755
// FileInfo describes a file.
@ -50,14 +50,17 @@ type FileInfo struct {
// FileOptions are the options when getting a file info.
type FileOptions struct {
Fs afero.Fs
Path string
Modify bool
Expand bool
ReadHeader bool
Token string
Checker rules.Checker
Content bool
Fs afero.Fs
Path string
Modify bool
Expand bool
ReadHeader bool
FolderSize bool
Token string
Checker rules.Checker
Content bool
RootPath string
AnotherPath string
}
type ImageResolution struct {
@ -65,10 +68,25 @@ type ImageResolution struct {
Height int `json:"height"`
}
// function that checks if given full path exists or not
// it helps to determine to which NFS we need to go IDC or KFS
func CheckIfExistsInPath(pathToCheck string) bool {
_, pathExistsErr := os.Stat(pathToCheck)
return !os.IsNotExist(pathExistsErr)
}
// NewFileInfo creates a File object from a path and a given user. This File
// object will be automatically filled depending on if it is a directory
// or a file. If it's a video file, it will also detect any subtitles.
func NewFileInfo(opts FileOptions) (*FileInfo, error) {
log.Printf("ROOT PATH - %v:", opts.RootPath)
log.Printf("ANOTHER PATH - %v:", opts.AnotherPath)
rootFilePath := opts.RootPath + opts.Path
if !CheckIfExistsInPath(rootFilePath) {
opts.Fs = afero.NewBasePathFs(afero.NewOsFs(), opts.AnotherPath)
} else {
opts.Fs = afero.NewBasePathFs(afero.NewOsFs(), opts.RootPath)
}
if !opts.Checker.Check(opts.Path) {
return nil, os.ErrPermission
}
@ -77,10 +95,16 @@ func NewFileInfo(opts FileOptions) (*FileInfo, error) {
if err != nil {
return nil, err
}
if file.IsDir && opts.FolderSize {
size, err := getFolderSize(file.RealPath())
if err != nil {
return nil, err
}
file.Size = size
}
if opts.Expand {
if file.IsDir {
if err := file.readListing(opts.Checker, opts.ReadHeader); err != nil { //nolint:govet
if err := file.readListing(opts.Checker, opts.ReadHeader, opts.RootPath, opts.AnotherPath); err != nil { //nolint:govet
return nil, err
}
return file, nil
@ -95,12 +119,31 @@ func NewFileInfo(opts FileOptions) (*FileInfo, error) {
return file, err
}
func getFolderSize(path string) (int64, error) {
var size int64
err := filepath.WalkDir(path, func(_ string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if !d.IsDir() {
info, err := d.Info()
if err != nil {
return err
}
size += info.Size()
}
return err
})
return size, err
}
func stat(opts FileOptions) (*FileInfo, error) {
var file *FileInfo
if lstaterFs, ok := opts.Fs.(afero.Lstater); ok {
info, _, err := lstaterFs.LstatIfPossible(opts.Path)
if err != nil {
log.Printf("stat current path error - %v:", err)
return nil, err
}
file = &FileInfo{
@ -349,11 +392,60 @@ func (i *FileInfo) detectSubtitles() {
}
}
func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
afs := &afero.Afero{Fs: i.Fs}
dir, err := afs.ReadDir(i.Path)
// async read dir and append the data to given FileInfo slice
func readDirAsync(fs afero.Fs, fullPath string, wg *sync.WaitGroup, resultSlice *[]os.FileInfo) {
defer wg.Done()
dir, err := afero.ReadDir(fs, fullPath)
if err != nil {
return err
log.Printf("Error reading directory: %v", err)
return
}
// Append the result to the slice
*resultSlice = append(*resultSlice, dir...)
}
func (i *FileInfo) readListing(checker rules.Checker, readHeader bool, rootPath, anotherPath string) error {
var wg sync.WaitGroup
var rootDir []os.FileInfo
var anotherDir []os.FileInfo
var finalDir []os.FileInfo
useAnotherDir := false
anotherFullPath := anotherPath + i.Path
rootFullPath := rootPath + i.Path
existsInRootPath := CheckIfExistsInPath(rootFullPath)
existsInAnotherPath := CheckIfExistsInPath(anotherFullPath)
log.Printf("%v %v %v %v", anotherFullPath, existsInAnotherPath, rootFullPath, existsInRootPath)
// if we aren't in home scenario use idcSite only because we are messing with opth.Path
// in some cases it can go to KFS site instead of going to IDC, so just to be sure...
if existsInRootPath && existsInAnotherPath && i.Path != "/" {
useAnotherDir = true
}
if existsInRootPath && !useAnotherDir {
wg.Add(1)
go readDirAsync(afero.NewOsFs(), rootFullPath, &wg, &rootDir)
}
if existsInAnotherPath {
wg.Add(1)
go readDirAsync(afero.NewOsFs(), anotherFullPath, &wg, &anotherDir)
}
// Wait for all goroutines to finish
wg.Wait()
if len(rootDir) > 0 && len(anotherDir) > 0 {
log.Printf("combining results")
finalDir = append(rootDir, anotherDir...)
} else if len(rootDir) > 0 {
finalDir = rootDir
} else {
finalDir = anotherDir
}
//in case of somehow the path exists in both paths due to some mess with opts.path use idc site
if useAnotherDir {
finalDir = anotherDir
}
listing := &Listing{
@ -362,14 +454,12 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
NumFiles: 0,
}
for _, f := range dir {
for _, f := range finalDir {
name := f.Name()
fPath := path.Join(i.Path, name)
if !checker.Check(fPath) {
continue
}
isSymlink, isInvalidLink := false, false
if IsSymlink(f.Mode()) {
isSymlink = true
@ -382,7 +472,6 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
isInvalidLink = true
}
}
file := &FileInfo{
Fs: i.Fs,
Name: name,
@ -393,9 +482,8 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
IsSymlink: isSymlink,
Extension: filepath.Ext(name),
Path: fPath,
currentDir: dir,
currentDir: finalDir,
}
if !file.IsDir && strings.HasPrefix(mime.TypeByExtension(file.Extension), "image/") {
resolution, err := calculateImageResolution(file.Fs, file.Path)
if err != nil {
@ -404,7 +492,6 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
file.Resolution = resolution
}
}
if file.IsDir {
listing.NumDirs++
} else {
@ -419,10 +506,8 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
}
}
}
listing.Items = append(listing.Items, file)
}
i.Listing = listing
return nil
}

View File

@ -7,8 +7,6 @@ import (
"path/filepath"
"github.com/spf13/afero"
"github.com/filebrowser/filebrowser/v2/files"
)
// MoveFile moves file from src to dst.
@ -42,13 +40,13 @@ func CopyFile(fs afero.Fs, source, dest string) error {
// Makes the directory needed to create the dst
// file.
err = fs.MkdirAll(filepath.Dir(dest), files.PermDir)
err = fs.MkdirAll(filepath.Dir(dest), 0666) //nolint:gomnd
if err != nil {
return err
}
// Create the destination file.
dst, err := fs.OpenFile(dest, os.O_RDWR|os.O_CREATE|os.O_TRUNC, files.PermFile)
dst, err := fs.OpenFile(dest, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) //nolint:gomnd
if err != nil {
return err
}

View File

@ -46,7 +46,7 @@
"postcss": "^8.4.31",
"prettier": "^3.0.1",
"terser": "^5.19.2",
"vite": "^4.5.2",
"vite": "^4.4.12",
"vite-plugin-compression2": "^0.10.3",
"vite-plugin-rewrite-all": "^1.0.1"
}
@ -5663,9 +5663,9 @@
"dev": true
},
"node_modules/vite": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.5.2.tgz",
"integrity": "sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==",
"version": "4.4.12",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.4.12.tgz",
"integrity": "sha512-KtPlUbWfxzGVul8Nut8Gw2Qe8sBzWY+8QVc5SL8iRFnpnrcoCaNlzO40c1R6hPmcdTwIPEDkq0Y9+27a5tVbdQ==",
"dev": true,
"dependencies": {
"esbuild": "^0.18.10",

View File

@ -52,7 +52,7 @@
"postcss": "^8.4.31",
"prettier": "^3.0.1",
"terser": "^5.19.2",
"vite": "^4.5.2",
"vite": "^4.4.12",
"vite-plugin-compression2": "^0.10.3",
"vite-plugin-rewrite-all": "^1.0.1"
},

View File

@ -16,8 +16,6 @@
[{[ if .Name -]}][{[ .Name ]}][{[ else ]}]File Browser[{[ end ]}]
</title>
<meta name="robots" content="noindex,nofollow">
<link
rel="icon"
type="image/png"

View File

@ -2,7 +2,7 @@
<div
class="shell"
:class="{ ['shell--hidden']: !showShell }"
:style="{ height: `${this.shellHeight}em`, direction: 'ltr' }"
:style="{ height: `${this.shellHeight}em` }"
>
<div
@pointerdown="startDrag()"

View File

@ -38,7 +38,7 @@
import { enableThumbs } from "@/utils/constants";
import { mapMutations, mapGetters, mapState } from "vuex";
import { filesize } from "@/utils";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
import { files as api } from "@/api";
import * as upload from "@/utils/upload";
@ -191,12 +191,7 @@ export default {
action(overwrite, rename);
},
itemClick: function (event) {
if (
!(event.ctrlKey || event.metaKey) &&
this.singleClick &&
!this.$store.state.multiple
)
this.open();
if (this.singleClick && !this.$store.state.multiple) this.open();
else this.click(event);
},
click: function (event) {

View File

@ -12,7 +12,7 @@
<div
class="card-action"
style="display: flex; align-items: center; justify-content: space-between"
style="display: flex; align-items: center; justify-content: space-between;"
>
<template v-if="user.perm.create">
<button
@ -20,7 +20,7 @@
@click="$refs.fileList.createDir()"
:aria-label="$t('sidebar.newFolder')"
:title="$t('sidebar.newFolder')"
style="justify-self: left"
style="justify-self: left;"
>
<span>{{ $t("sidebar.newFolder") }}</span>
</button>

View File

@ -89,7 +89,7 @@
<script>
import { mapState, mapGetters } from "vuex";
import { filesize } from "@/utils";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
import { files as api } from "@/api";
export default {
@ -133,13 +133,14 @@ export default {
: this.req.items[this.selected[0]].isDir)
);
},
resolution: function () {
resolution: function() {
if (this.selectedCount === 1) {
const selectedItem = this.req.items[this.selected[0]];
if (selectedItem && selectedItem.type === "image") {
if (selectedItem && selectedItem.type === 'image') {
return selectedItem.resolution;
}
} else if (this.req && this.req.type === "image") {
}
else if (this.req && this.req.type === 'image') {
return this.req.resolution;
}
return null;

View File

@ -11,7 +11,7 @@
<div
class="card-action"
style="display: flex; align-items: center; justify-content: space-between"
style="display: flex; align-items: center; justify-content: space-between;"
>
<template v-if="user.perm.create">
<button
@ -19,7 +19,7 @@
@click="$refs.fileList.createDir()"
:aria-label="$t('sidebar.newFolder')"
:title="$t('sidebar.newFolder')"
style="justify-self: left"
style="justify-self: left;"
>
<span>{{ $t("sidebar.newFolder") }}</span>
</button>

View File

@ -27,7 +27,6 @@ import Share from "./Share.vue";
import Upload from "./Upload.vue";
import ShareDelete from "./ShareDelete.vue";
import Sidebar from "../Sidebar.vue";
import DiscardEditorChanges from "./DiscardEditorChanges.vue";
import { mapGetters, mapState } from "vuex";
import buttons from "@/utils/buttons";
@ -48,8 +47,7 @@ export default {
ReplaceRename,
Upload,
ShareDelete,
Sidebar,
DiscardEditorChanges,
Sidebar
},
data: function () {
return {
@ -64,16 +62,17 @@ export default {
window.addEventListener("keydown", (event) => {
if (this.currentPrompt == null) return;
const promptName = this.currentPrompt.prompt;
const prompt = this.$refs[promptName];
let prompt = this.$refs.currentComponent;
if (event.code === "Escape") {
// Esc!
if (event.keyCode === 27) {
event.stopImmediatePropagation();
this.$store.commit("closeHovers");
}
if (event.code === "Enter") {
switch (promptName) {
// Enter
if (event.keyCode == 13) {
switch (this.currentPrompt.prompt) {
case "delete":
prompt.submit();
break;

View File

@ -128,7 +128,7 @@
<script>
import { mapState, mapGetters } from "vuex";
import { share as api, pub as pub_api } from "@/api";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
import Clipboard from "clipboard";
export default {

View File

@ -220,10 +220,6 @@ body.rtl .card .card-title>*:first-child {
text-align: right;
}
body.rtl .card .card-action {
text-align: left;
}
.card .card-content.full {
padding-bottom: 0;
overflow: auto;

View File

@ -38,8 +38,7 @@
"update": "Update",
"upload": "Upload",
"openFile": "Open file",
"continue": "Continue",
"discardChanges": "Discard"
"continue": "Continue"
},
"download": {
"downloadFile": "Download File",
@ -163,8 +162,7 @@
"uploadFiles": "Uploading {files} files...",
"uploadMessage": "Select an option to upload.",
"optionalPassword": "Optional password",
"resolution": "Resolution",
"discardEditorChanges": "Are you sure you wish to discard the changes you've made?"
"resolution": "Resolution"
},
"search": {
"images": "Images",

View File

@ -5,9 +5,8 @@
"copy": "העתקה",
"copyFile": "העתק קובץ",
"copyToClipboard": "העתק ללוח",
"copyDownloadLinkToClipboard": "העתק קישור הורדה ללוח",
"create": "צור",
"delete": "מחק",
"create": "יצירה",
"delete": "מחיקה",
"download": "הורדה",
"file": "קובץ",
"folder": "תיקייה",
@ -19,7 +18,7 @@
"new": "חדש",
"next": "הבא",
"ok": "אישור",
"permalink": "יצירת קישור קבוע",
"permalink": "צור קישור קבוע",
"previous": "הקודם",
"publish": "פרסום",
"rename": "שינוי שם",
@ -37,18 +36,13 @@
"toggleSidebar": "פתיחת/סגירת סרגל צד",
"update": "עדכון",
"upload": "העלאה",
"openFile": "פתח קובץ",
"continue": "המשך",
"discardChanges": "זריקת השינויים"
"openFile": "פתח קובץ"
},
"download": {
"downloadFile": "הורד קובץ",
"downloadFolder": "הורד תיקייה",
"downloadSelected": "הורד קבצים שנבחרו"
},
"upload": {
"abortUpload": "האם אתה בטוח שברצונך להפסיק את ההעלאה?"
},
"errors": {
"forbidden": "אין לך הרשאות גישה",
"internal": "משהו השתבש",
@ -72,7 +66,7 @@
"sortByLastModified": "מיין לפי השינוי האחרון",
"sortByName": "מיין לפי שם",
"sortBySize": "מיין לפי גודל",
"noPreview": "לא זמינה תצוגה מקדימה לקובץ זה"
"noPreview": "תצוגה מקדימה לא זמינה לקובץ זה"
},
"help": {
"click": "בחר קובץ או תיקייה",
@ -161,8 +155,7 @@
"upload": "העלאה",
"uploadFiles": "מעלה {files} קבצים...",
"uploadMessage": "בחר אפשרות העלאה.",
"optionalPassword": "סיסמא אופציונלית",
"discardEditorChanges": "האם אתה בטוח שברצונך לבטל את השינויים שביצעת?"
"optionalPassword": "סיסמא אופציונלית"
},
"search": {
"images": "תמונות",
@ -197,7 +190,6 @@
"customStylesheet": "עיצוב מותאם אישית (Stylesheet)",
"defaultUserDescription": "הגדרות ברירת המחדל למשתמשים חדשים",
"disableExternalLinks": "השבת קישורים חיצוניים (למעט תיעוד)",
"disableUsedDiskPercentage": "אל תציג גרף שימוש בדיסק",
"documentation": "תיעוד",
"examples": "דוגמאות",
"executeOnShell": "בצע במסוף",
@ -226,7 +218,7 @@
"share": "שיתוף קבצים"
},
"permissions": "הרשאות",
"permissionsHelp": "אתה יכול להגדיר את המשתמש להיות מנהל מערכת או לבחור את ההרשאות בנפרד. אם תבחר \"מנהל מערכת\", כל ההרשאות יינתנו אוטומטית. ניהול המשתמשים נשאר הרשאה של מנהל מערכת.\n",
"permissionsHelp": "אתה יכול להגדיר את המשתמש להיות מנהל מערכת או לבחור את ההרשאות בנפרד. אם תבחר \"מנהל מערכת\", כל ההרשאות ייבחרו אוטומטית. ניהול המשתמשים נשאר הרשאה של מנהל מערכת.\n",
"profileSettings": "הגדרות פרופיל",
"ruleExample1": "מנע גישה לקבצים נסתרים (כל קובץ/תיקייה שמתחיל בנקודה, לדוגמא .git)",
"ruleExample2": "חסימת גישה לקובץ בשם Caddyfile בהיקף הראשי.",

View File

@ -3,87 +3,76 @@
"cancel": "キャンセル",
"close": "閉じる",
"copy": "コピー",
"copyFile": "ファイルのコピー",
"copyToClipboard": "共有リンクをコピー",
"copyDownloadLinkToClipboard": "ダウンロードリンクをコピー",
"copyFile": "ファイルをコピー",
"copyToClipboard": "クリップボードにコピー",
"create": "作成",
"delete": "削除",
"download": "ダウンロード",
"file": "ファイル",
"folder": "フォルダー",
"hideDotfiles": "ドットで始まるファイルを表示しない",
"hideDotfiles": "",
"info": "情報",
"more": "さらに",
"more": "More",
"move": "移動",
"moveFile": "ファイル移動",
"moveFile": "ファイル移動",
"new": "新規",
"next": "次",
"next": "次",
"ok": "OK",
"permalink": "パーマリンクを取得",
"previous": "前",
"publish": "公開",
"rename": "名前変更",
"replace": "置換する",
"permalink": "固定リンク",
"previous": "前",
"publish": "発表",
"rename": "名前変更",
"replace": "置き換える",
"reportIssue": "問題を報告",
"save": "保存",
"schedule": "スケジュール",
"search": "検索",
"select": "選択",
"selectMultiple": "複数選択",
"share": "共有",
"shell": "シェルの切り替え",
"submit": "送信",
"switchView": "表示の切り替え",
"toggleSidebar": "サイドバーの切り替え",
"share": "シェア",
"shell": "Toggle shell",
"switchView": "表示を切り替わる",
"toggleSidebar": "サイドバーを表示する",
"update": "更新",
"upload": "アップロード",
"openFile": "ファイルを開く",
"continue": "続行"
"upload": "アップロード"
},
"download": {
"downloadFile": "ファイルのダウンロード",
"downloadFolder": "フォルダーのダウンロード",
"downloadSelected": "選択した項目のダウンロード"
},
"upload": {
"abortUpload": "アップロードをキャンセルしますか?"
"downloadFile": "Download File",
"downloadFolder": "Download Folder",
"downloadSelected": ""
},
"errors": {
"forbidden": "これにアクセスする権限がありません。",
"forbidden": "You don't have permissions to access this.",
"internal": "内部エラーが発生しました。",
"notFound": "リソースが見つかりませんでした。",
"connection": "サーバーに接続できませんでした。"
"notFound": "リソースが見つからなりませんでした。"
},
"files": {
"body": "本文",
"clear": "消去",
"clear": "クリアー",
"closePreview": "プレビューを閉じる",
"files": "ファイル",
"folders": "フォルダ",
"folders": "フォルダ",
"home": "ホーム",
"lastModified": "新日時",
"loading": "読み込み中…",
"lonely": "ここには何もないようです…",
"lastModified": "最終変更",
"loading": "ローディング...",
"lonely": "ここには何もない...",
"metadata": "メタデータ",
"multipleSelectionEnabled": "複数選択有効になっています",
"multipleSelectionEnabled": "複数選択有効",
"name": "名前",
"size": "サイズ",
"sortByLastModified": "更新日時で並べ替え",
"sortByName": "名前で並べ替え",
"sortBySize": "サイズで並べ替え",
"noPreview": "プレビューはこのファイルでは利用できません"
"sortByLastModified": "最終変更日付によるソート",
"sortByName": "名前によるソート",
"sortBySize": "サイズによるソート"
},
"help": {
"click": "ファイルやフォルダーを選択",
"click": "ファイルやディレクトリを選択",
"ctrl": {
"click": "複数のファイルやフォルダーを選択",
"f": "検索画面を開く",
"s": "現在のフォルダーにあるファイルを保存またはダウンロード"
"click": "複数のファイルやディレクトリを選択",
"f": "検索を有効にする",
"s": "ファイルを保存またはカレントディレクトリをダウンロード"
},
"del": "選択した項目を削除",
"doubleClick": "ファイルやフォルダーを開く",
"esc": "選択を解除/ダイアログを閉じる",
"f1": "ヘルプを表示",
"doubleClick": "ファイルやディレクトリをオープン",
"esc": "選択をクリアーまたはプロンプトを閉じる",
"f1": "このヘルプを表示",
"f2": "ファイルの名前を変更",
"help": "ヘルプ"
},
@ -92,193 +81,180 @@
"hu": "Magyar",
"ar": "العربية",
"de": "Deutsch",
"el": "Ελληνικά",
"en": "English",
"es": "Español",
"fr": "Français",
"is": "Icelandic",
"is": "",
"it": "Italiano",
"ja": "日本語",
"ko": "한국어",
"nlBE": "Dutch (Belgium)",
"nlBE": "",
"pl": "Polski",
"pt": "Português",
"ptBR": "Português (Brasil)",
"ro": "Romanian",
"ro": "",
"ru": "Русский",
"sk": "Slovenčina",
"svSE": "Swedish (Sweden)",
"tr": "Türkçe",
"svSE": "",
"tr" : "Türkçe",
"ua": "Українська",
"zhCN": "中文 (简体)",
"zhTW": "中文 (繁體)"
},
"login": {
"createAnAccount": "アカウントを作成",
"loginInstead": "ログインする",
"createAnAccount": "Create an account",
"loginInstead": "Already have an account",
"password": "パスワード",
"passwordConfirm": "パスワード(確認用)",
"passwordsDontMatch": "パスワードが一致しません",
"signup": "アカウント作成",
"passwordConfirm": "Password Confirmation",
"passwordsDontMatch": "Passwords don't match",
"signup": "Signup",
"submit": "ログイン",
"username": "ユーザ名",
"usernameTaken": "ユーザー名はすでに取得されています",
"wrongCredentials": "ユーザ名またはパスワードが間違っています"
"username": "ユーザ名",
"usernameTaken": "Username already taken",
"wrongCredentials": "ユーザ名またはパスワードが間違っています"
},
"permanent": "永久",
"prompts": {
"copy": "コピー",
"copyMessage": "ファイルをコピーする場所を選択してください:",
"copyMessage": "コピーの目標ディレクトリを選択してください:",
"currentlyNavigating": "現在閲覧しているディレクトリ:",
"deleteMessageMultiple": "{count} 個のファイルを削除してもよろしいですか?",
"deleteMessageSingle": "このファイル/フォルダーを削除してもよろしいですか?",
"deleteMessageShare": "共有中のファイル({path})を削除してもよろしいですか?",
"deleteTitle": "ファイルの削除",
"displayName": "表示名:",
"download": "ファイルのダウンロード",
"downloadMessage": "ダウンロードする際の圧縮形式を選んでください:",
"error": "エラーが発生しました",
"deleteMessageMultiple": "{count} つのファイルを本当に削除してよろしいですか。",
"deleteMessageSingle": "このファイル/フォルダを本当に削除してよろしいですか。",
"deleteTitle": "ファイルを削除",
"displayName": "名前:",
"download": "ファイルをダウンロード",
"downloadMessage": "圧縮形式を選択してください。",
"error": "あるエラーが発生しました。",
"fileInfo": "ファイル情報",
"filesSelected": "{count} 個のファイル/フォルダーが選択されています",
"lastModified": "新日時",
"filesSelected": "{count} つのファイルは選択されました。",
"lastModified": "最終変更",
"move": "移動",
"moveMessage": "ファイル/フォルダーの新しいハウスを選択してください:",
"newArchetype": "archetype に基づいて新しい投稿を作成します。ファイルは content フォルダーに作成されます。",
"newDir": "新規フォルダー",
"newDirMessage": "フォルダーの名前を入力してください:",
"newFile": "新規ファイル",
"newFileMessage": "ファイルの名前を入力してください:",
"numberDirs": "ディレクトリ数",
"numberFiles": "ファイル数",
"rename": "名前変更",
"renameMessage": "変更後のファイルの名前を入力してください",
"replace": "ファイルの置き換え",
"replaceMessage": "アップロードしようとしているファイルと既存のファイルの名前が重複しています。既存のものを置き換えずにアップロードを続けるか、既存のものを置き換えますか?\n",
"moveMessage": "移動の目標ディレクトリを選択してください:",
"newArchetype": "ある元型に基づいて新しいポストを作成します。ファイルは コンテンツフォルダに作成されます。",
"newDir": "新しいディレクトリを作成",
"newDirMessage": "新しいディレクトリの名前を入力してください。",
"newFile": "新しいファイルを作成",
"newFileMessage": "新しいファイルの名前を入力してください。",
"numberDirs": "ディレクトリ数",
"numberFiles": "ファイル数",
"rename": "名前変更",
"renameMessage": "名前を変更しようファイルは:",
"replace": "置き換え",
"replaceMessage": "アップロードするファイルの中でかち合う名前が一つあります。 既存のファイルを置き換えりませんか。\n",
"schedule": "スケジュール",
"scheduleMessage": "この投稿の公開予定日時を選んでください。",
"scheduleMessage": "このポストの発表日付をスケジュールしてください。",
"show": "表示",
"size": "サイズ",
"upload": "アップロード",
"uploadFiles": "{files} 個のファイルをアップロードしています…",
"uploadMessage": "アップロードするオプションを選択してください。",
"optionalPassword": "パスワード(オプション)"
"upload": "",
"uploadMessage": ""
},
"search": {
"images": "画像",
"music": "音楽",
"pdf": "PDF",
"pressToSearch": "エンターを押して検索します",
"search": "検索",
"typeToSearch": "検索の種類",
"types": "ファイルの種類",
"video": "動画"
"pressToSearch": "Press enter to search...",
"search": "検索...",
"typeToSearch": "Type to search...",
"types": "種類",
"video": "ビデオ"
},
"settings": {
"admin": "管理者",
"administrator": "管理者",
"allowCommands": "コマンドの実行",
"allowEdit": "ファイルやフォルダーの編集、名前の変更、削除",
"allowNew": "ファイルやフォルダーの新規作成",
"allowPublish": "新しい投稿やページの公開",
"allowSignup": "ユーザーの新規登録を許可",
"avoidChanges": "(変更しない場合は空白のままにしてください)",
"branding": "ブランディング",
"brandingDirectoryPath": "ブランディングのディレクトリへのパス",
"brandingHelp": "インスタンスの名前の変更、ロゴの変更、カスタムスタイルの追加、GitHub への外部リンクの無効化など、File Browser の見た目や使い勝手をカスタマイズすることができます。\nカスタムブランディングの詳細については、{0}をご覧ください。",
"changePassword": "パスワードの変更",
"commandRunner": "コマンドランナー",
"commandRunnerHelp": "ここでは、指定したイベントの際に実行されるコマンドを設定することができます。1行に1つずつ書く必要があります。環境変数として {0} や {1} が使用可能で、{0} は {1} に関連した変数として扱われます。この機能と使用可能な環境変数の詳細については、{2}をお読みください。",
"commandsUpdated": "コマンドを更新しました!",
"createUserDir": "新規ユーザー追加時にユーザーのホームディレクトリを自動生成する",
"tusUploads": "チャンクされたファイルアップロード",
"tusUploadsHelp": "File Browser はチャンクされたファイルアップロードをサポートしており、信頼性の低いネットワーク上でも、効率的で信頼性の高い、再開可能なチャンクされたファイルアップロードを作成することができます。",
"tusUploadsChunkSize": "1チャンクあたりのリクエストの最大サイズ。バイト数を示す整数か、10MB、1GBなどの文字列を入力できます。",
"tusUploadsRetryCount": "チャンクのアップロードに失敗した場合の再試行回数。",
"userHomeBasePath": "ユーザーのホームディレクトリのベースパス",
"userScopeGenerationPlaceholder": "スコープは自動生成されます",
"createUserHomeDirectory": "ユーザーのホームディレクトリを作成する",
"customStylesheet": "カスタムスタイルシート",
"defaultUserDescription": "これらは新規ユーザーのデフォルト設定です。",
"disableExternalLinks": "外部リンクを無効にする(ドキュメントへのリンクを除く)",
"disableUsedDiskPercentage": "ディスク使用率のグラフを無効にする",
"documentation": "ドキュメント",
"allowEdit": "ファイルやディレクトリの編集、名前変更と削除",
"allowNew": "ファイルとディレクトリの作成",
"allowPublish": "ポストとぺーじの発表",
"allowSignup": "Allow users to signup",
"avoidChanges": "(変更を避けるために空白にしてください)",
"branding": "Branding",
"brandingDirectoryPath": "Branding directory path",
"brandingHelp": "You can customize how your File Browser instance looks and feels by changing its name, replacing the logo, adding custom styles and even disable external links to GitHub.\nFor more information about custom branding, please check out the {0}.",
"changePassword": "パスワードを変更",
"commandRunner": "Command runner",
"commandRunnerHelp": "Here you can set commands that are executed in the named events. You must write one per line. The environment variables {0} and {1} will be available, being {0} relative to {1}. For more information about this feature and the available environment variables, please read the {2}.",
"commandsUpdated": "コマンドは更新されました!",
"createUserDir": "Auto create user home dir while adding new user",
"customStylesheet": "カスタムスタイルシ ート",
"defaultUserDescription": "This are the default settings for new users.",
"disableExternalLinks": "Disable external links (except documentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentation",
"examples": "例",
"executeOnShell": "シェルで実行する",
"executeOnShellDescription": "デフォルトでは、File Browser はバイナリを直接呼び出してコマンドを実行します。代わりにシェルBash や PowerShell など)で実行したい場合は、必要な引数やフラグをここで指定します。値が指定されている場合、実行するコマンドが引数として追加されます。これは、ユーザーコマンドとイベントフックの両方に適用されます。",
"globalRules": "これはグローバルな許可と不許可のルールセットです。これはすべてのユーザーに適用されます。ユーザーごとに特定のルールを設定することで、これらのルールを上書きすることができます。",
"executeOnShell": "Execute on shell",
"executeOnShellDescription": "By default, File Browser executes the commands by calling their binaries directly. If you want to run them on a shell instead (such as Bash or PowerShell), you can define it here with the required arguments and flags. If set, the command you execute will be appended as an argument. This apply to both user commands and event hooks.",
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
"globalSettings": "グローバル設定",
"hideDotfiles": "ドットで始まるファイルを表示しない",
"insertPath": "パスを入力してください",
"insertRegex": "正規表現を入力してください",
"instanceName": "インスタンス名",
"hideDotfiles": "",
"insertPath": "Insert the path",
"insertRegex": "Insert regex expression",
"instanceName": "Instance name",
"language": "言語",
"lockPassword": "ユーザーがパスワードを変更できないようにする",
"lockPassword": "新しいパスワードを変更に禁止",
"newPassword": "新しいパスワード",
"newPasswordConfirm": "新しいパスワード(再入力)",
"newUser": "新規ユーザー作成",
"newPasswordConfirm": "新しいパスワードを確認します",
"newUser": "新しいユーザー",
"password": "パスワード",
"passwordUpdated": "パスワードを更新しました!",
"path": "パス",
"passwordUpdated": "パスワードは更新されました!",
"path": "",
"perm": {
"create": "ファイルやフォルダーの作成",
"delete": "ファイルやフォルダーの削除",
"download": "ダウンロード",
"execute": "コマンドの実行",
"modify": "ファイルの編集",
"rename": "ファイルやフォルダーの編集・移動",
"share": "ファイルの共有"
"create": "Create files and directories",
"delete": "Delete files and directories",
"download": "Download",
"execute": "Execute commands",
"modify": "Edit files",
"rename": "Rename or move files and directories",
"share": "Share files"
},
"permissions": "権限",
"permissionsHelp": "ユーザーを管理者に設定するか、その他の権限を個別に選択することができます。「管理者」を選択すると、他のオプションはすべて自動的にチェックされます。ユーザーを管理するには管理者権限が必要です。\n",
"profileSettings": "プロフィール設定",
"ruleExample1": ".git や .gitignore のようなドットから始まるファイルへのアクセスを禁止します。\n",
"ruleExample2": "スコープのルートにある Caddyfile という名前のファイルへのアクセスを禁止します。",
"rules": "ルール",
"rulesHelp": "ここでは、特定のユーザーに対して許可と不許可のルールを設定することができます。ブロックされたファイルはリストに表示されず、ユーザはアクセスできなくなります。正規表現とユーザースコープからの相対パスをサポートしています。\n",
"scope": "スコープ",
"setDateFormat": "正確な日時表記を使用する",
"settingsUpdated": "設定を更新しました!",
"shareDuration": "共有期間",
"shareManagement": "共有の管理",
"shareDeleted": "ファイルの共有を削除しました!",
"singleClick": "ダブルクリックの代わりにクリックでファイルやフォルダーを開く",
"permissionsHelp": "あなたはユーザーを管理者に設定し、または権限を個々に設定しできます。\"管理者\"を選択する場合、その他のすべての選択肢は自動的に設定されます。ユーザーの管理は管理者の権限として保留されました。",
"profileSettings": "プロファイル設定",
"ruleExample1": "各フォルダに名前はドットで始まるファイル(例えば、.git、.gitignoreへのアクセスを制限します。",
"ruleExample2": "範囲のルートパスに名前は Caddyfile のファイルへのアクセスを制限します。",
"rules": "規則",
"rulesHelp": "ここに、あなたはこのユーザーの許可または拒否規則を設定できます。ブロックされたファイルはリストに表示されません、それではアクセスも制限されます。正規表現(regex)のサポートと範囲に相対のパスが提供されています。",
"scope": "範囲",
"settingsUpdated": "設定は更新されました!",
"shareDuration": "",
"shareManagement": "",
"singleClick": "",
"themes": {
"dark": "ダーク",
"light": "ライト",
"title": "テーマ"
"dark": "",
"light": "",
"title": ""
},
"user": "ユーザー",
"userCommands": "コマンド",
"userCommandsHelp": "このユーザーが使用可能なコマンドをスペースで区切ったリスト。例:\n",
"userCreated": "ユーザーを作成しました!",
"userDefaults": "ユーザーのデフォルト設定",
"userDeleted": "ユーザーを削除しました!",
"userCommands": "ユーザーのコマンド",
"userCommandsHelp": "空白区切りの有効のコマンドのリストを指定してください。例:",
"userCreated": "ユーザーは作成されました!",
"userDefaults": "User default settings",
"userDeleted": "ユーザーは削除されました!",
"userManagement": "ユーザー管理",
"userUpdated": "ユーザーを更新しました!",
"userUpdated": "ユーザーは更新されました!",
"username": "ユーザー名",
"users": "ユーザー"
},
"sidebar": {
"help": "ヘルプ",
"hugoNew": "Hugo New",
"login": "ログイン",
"login": "Login",
"logout": "ログアウト",
"myFiles": "マイファイル",
"newFile": "新規ファイル",
"newFolder": "新規フォルダー",
"myFiles": "私のファイル",
"newFile": "新しいファイルを作成",
"newFolder": "新しいフォルダを作成",
"preview": "プレビュー",
"settings": "設定",
"signup": "サインアップ",
"signup": "Signup",
"siteSettings": "サイト設定"
},
"success": {
"linkCopied": "リンクをコピーしました!"
"linkCopied": "リンクがコピーされました!"
},
"time": {
"days": "日",
"hours": "時間",
"minutes": "分",
"seconds": "秒",
"unit": "時間単位"
"unit": "時間単位"
}
}

View File

@ -1,5 +1,5 @@
import * as i18n from "@/i18n";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
const mutations = {
closeHovers: (state) => {

View File

@ -183,7 +183,7 @@
import { mapState, mapMutations, mapGetters } from "vuex";
import { pub as api } from "@/api";
import { filesize } from "@/utils";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
import HeaderBar from "@/components/header/HeaderBar.vue";
import Action from "@/components/header/Action.vue";

View File

@ -103,15 +103,13 @@ export default {
if (theme == "dark") {
this.editor.setTheme("ace/theme/twilight");
}
this.editor.focus();
},
methods: {
back() {
let uri = url.removeLastDir(this.$route.path) + "/";
this.$router.push({ path: uri });
},
keyEvent(event) {
if (event.code === "Escape") {
this.close();
}
if (!event.ctrlKey && !event.metaKey) {
return;
}
@ -129,7 +127,6 @@ export default {
try {
await api.put(this.$route.path, this.editor.getValue());
this.editor.session.getUndoManager().markClean();
buttons.success(button);
} catch (e) {
buttons.done(button);
@ -137,11 +134,6 @@ export default {
}
},
close() {
if (!this.editor.session.getUndoManager().isClean()) {
this.$store.commit("showHover", "discardEditorChanges");
return;
}
this.$store.commit("updateRequest", {});
let uri = url.removeLastDir(this.$route.path) + "/";

View File

@ -63,7 +63,7 @@
<script>
import { share as api, users } from "@/api";
import { mapState, mapMutations } from "vuex";
import moment from "moment/min/moment-with-locales";
import moment from "moment";
import Clipboard from "clipboard";
import Errors from "@/views/Errors.vue";

2
go.mod
View File

@ -2,6 +2,8 @@ module github.com/filebrowser/filebrowser/v2
go 1.20
replace "github.com/filebrowser/filebrowser/v2/" v1.0.0 => .
require (
github.com/asdine/storm/v3 v3.2.1
github.com/disintegration/imaging v1.6.2

View File

@ -1,5 +1,3 @@
#!/bin/sh
PORT=${FB_PORT:-$(jq .port /.filebrowser.json)}
ADDRESS=${FB_ADDRESS:-$(jq .address /.filebrowser.json)}
ADDRESS=${ADDRESS:-localhost}
curl -f http://$ADDRESS:$PORT/health || exit 1
curl -f http://localhost:$PORT/health || exit 1

View File

@ -11,34 +11,53 @@ import (
"path/filepath"
"strings"
"github.com/shirou/gopsutil/v3/disk"
"github.com/spf13/afero"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/fileutils"
"github.com/shirou/gopsutil/v3/disk"
"github.com/spf13/afero"
)
var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: true,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Content: true,
var resourceGetSizeHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
folder, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: true,
FolderSize: true,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Content: true,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err != nil {
return errToStatus(err), err
}
return renderJSON(w, r, folder)
})
var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: true,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Content: true,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err != nil {
return errToStatus(err), err
}
if file.IsDir {
file.Listing.Sorting = d.user.Sorting
file.Listing.ApplySort()
return renderJSON(w, r, file)
}
if checksum := r.URL.Query().Get("checksum"); checksum != "" {
err := file.Checksum(checksum)
if err == errors.ErrInvalidOption {
@ -50,7 +69,6 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
// do not waste bandwidth if we just want the checksum
file.Content = ""
}
return renderJSON(w, r, file)
})
@ -61,12 +79,14 @@ func resourceDeleteHandler(fileCache FileCache) handleFunc {
}
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err != nil {
return errToStatus(err), err
@ -98,17 +118,19 @@ func resourcePostHandler(fileCache FileCache) handleFunc {
// Directories creation on POST.
if strings.HasSuffix(r.URL.Path, "/") {
err := d.user.Fs.MkdirAll(r.URL.Path, files.PermDir)
err := d.user.Fs.MkdirAll(r.URL.Path, 0775) //nolint:gomnd
return errToStatus(err), err
}
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err == nil {
if r.URL.Query().Get("override") != "true" {
@ -256,12 +278,12 @@ func addVersionSuffix(source string, fs afero.Fs) string {
func writeFile(fs afero.Fs, dst string, in io.Reader) (os.FileInfo, error) {
dir, _ := path.Split(dst)
err := fs.MkdirAll(dir, files.PermDir)
err := fs.MkdirAll(dir, 0775) //nolint:gomnd
if err != nil {
return nil, err
}
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, files.PermFile)
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) //nolint:gomnd
if err != nil {
return nil, err
}
@ -309,12 +331,14 @@ func patchAction(ctx context.Context, action, src, dst string, d *data, fileCach
dst = path.Clean("/" + dst)
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: src,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: false,
Checker: d,
Fs: d.user.Fs,
Path: src,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: false,
Checker: d,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err != nil {
return err
@ -339,13 +363,15 @@ type DiskUsageResponse struct {
var diskUsage = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: false,
Checker: d,
Content: false,
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
ReadHeader: false,
Checker: d,
Content: false,
RootPath: d.server.Root,
AnotherPath: d.server.AnotherPath,
})
if err != nil {
return errToStatus(err), err

View File

@ -37,6 +37,7 @@ func (s *Settings) GetRules() []rules.Rule {
// Server specific settings.
type Server struct {
Root string `json:"root"`
AnotherPath string `json:"anotherPath"`
BaseURL string `json:"baseURL"`
Socket string `json:"socket"`
TLSKey string `json:"tlsKey"`