@samitouri / QOSami-HFS / commits / 32e670ea

admin/options: show_hidden_files (Windows only)

Massimo Melina committed Sep 1, 2024 at 23:52 UTC 32e670eaaf8c95b50694e224db95725af57b0601
2 files changed +10 -21
admin/src/OptionsPage.ts
+5 -3
@@ -63,6 +63,7 @@ export default function OptionsPage() {
63 sm: 4,
64 }
65 const httpsEnabled = values.https_port >= 0
66 + const isWindows = status?.platform === 'win32'
67 return h(Form, {
68 sx: { maxWidth: '60em' },
69 values,
@@ -194,13 +195,14 @@ export default function OptionsPage() {
195 label: "Min. available disk space", helperText: "Reject uploads that don't comply" },
196
197 h(Section, { title: "Others" }),
197 - { k: 'keep_session_alive', comp: BoolField, sm: true, helperText: "Keeps you logged in while the page is left open and the computer is on" },
198 + { k: 'keep_session_alive', comp: BoolField, sm: 4, md: 6, helperText: "Keeps you logged in while the page is left open and the computer is on" },
199 { k: 'session_duration', comp: NumberField, sm: 4, md: 3, min: 5, unit: "seconds", required: true },
200 { k: 'zip_calculate_size_for_seconds', comp: NumberField, sm: 4, md: 3, label: "Calculate ZIP size for", unit: "seconds",
201 helperText: "If time is not enough, the browser will not show download percentage" },
202
202 - { k: 'descript_ion', comp: BoolField, label: "Enable comments", helperText: "In file DESCRIPT.ION" },
203 - { k: 'descript_ion_encoding', label: "Encoding of file DESCRIPT.ION", comp: SelectField, disabled: !values.descript_ion,
203 + { k: 'descript_ion', comp: BoolField, ...isWindows && { sm: 4, md: 3 }, label: "Enable comments", helperText: "In file DESCRIPT.ION" },
204 + isWindows && { k: 'show_hidden_files', comp: BoolField, sm: 4, md: 3, helperText: "Showing makes search faster" },
205 + { k: 'descript_ion_encoding', sm: 4, md: 6, label: "Encoding of file DESCRIPT.ION", comp: SelectField, disabled: !values.descript_ion,
206 options: ['utf8',720,775,819,850,852,862,869,874,808, ..._.range(1250,1257),10029,20866,21866] },
207
208 { k: 'open_browser_at_start', comp: BoolField, label: "Open Admin-panel at start",
src/vfs.ts
+5 -18
@@ -3,23 +3,8 @@
3 import fs from 'fs/promises'
4 import { basename, dirname, join, resolve } from 'path'
5 import {
6 - dirStream,
7 - getOrSet,
8 - isDirectory,
9 - makeMatcher,
10 - setHidden,
11 - onlyTruthy,
12 - isValidFileName,
13 - throw_,
14 - VfsPerms,
15 - Who,
16 - isWhoObject,
17 - WHO_ANY_ACCOUNT,
18 - defaultPerms,
19 - PERM_KEYS,
20 - removeStarting,
21 - HTTP_SERVER_ERROR,
22 - try_
6 + dirStream, getOrSet, isDirectory, makeMatcher, setHidden, onlyTruthy, isValidFileName, throw_, VfsPerms, Who,
7 + isWhoObject, WHO_ANY_ACCOUNT, defaultPerms, PERM_KEYS, removeStarting, HTTP_SERVER_ERROR, try_
8 } from './misc'
9 import Koa from 'koa'
10 import _ from 'lodash'
@@ -30,6 +15,8 @@ import { expandUsername } from './perm'
15 import { getCurrentUsername } from './auth'
16 import { Stats } from 'node:fs'
17
18 +const showHiddenFiles = defineConfig('show_hidden_files', false)
19 +
20 type Masks = Record<string, VfsNode & { maskOnly?: 'files' | 'folders' }>
21
22 export interface VfsNodeStored extends VfsPerms {
@@ -298,7 +285,7 @@ export async function* walkNode(parent: VfsNode, {
285 try {
286 let lastDir = prefixPath.slice(0, -1) || '.'
287 parentsCache.set(lastDir, parent)
301 - for await (const entry of dirStream(source, { depth, onlyFolders, hidden: false })) {
288 + for await (const entry of dirStream(source, { depth, onlyFolders, hidden: showHiddenFiles.get() })) {
289 if (ctx?.req.aborted)
290 return
291 const {path} = entry