mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-16 22:15:55 -05:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3800cd572 | ||
|
|
68ff727dd9 |
No files matched your search
@@ -2,6 +2,15 @@
|
||||
|
||||
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).
|
||||
|
||||
## v2.1.6
|
||||
|
||||
**Security**:
|
||||
- [High] Archive extraction now bounds symlink target resolution under the extract destination and rejects absolute or `..` link text, including chained symlinks created during the same extract, closing a follow-up escape path related to GHSA-jg32-ppcc-ph62 (#3404)
|
||||
|
||||
**Bug Fixes**:
|
||||
- fix(utils): `IsTextFile` reads only an 8KB sample instead of the whole file, avoiding excessive memory use when classifying large files for the editor, file watcher, and subtitle checks (#3405)
|
||||
- fix(frontend): standard source usage bar (`source` and `source-alt` sidebar categories) now shows per-user scope quota (used vs cap) from `GET /api/settings/sources` instead of the parent source partition size when a scope quota is configured, and keeps that quota across realtime `sourceUpdate` events (#3402)
|
||||
|
||||
## v2.1.5
|
||||
|
||||
**Security**:
|
||||
|
||||
@@ -2,6 +2,7 @@ import { settingsApi } from "@/api/index.js"
|
||||
import i18n from "@/i18n/index.ts"
|
||||
import { notify } from "@/notify/index.ts"
|
||||
import { mutations, state } from "@/store/index.ts"
|
||||
import { getObjectProperty } from "@/utils/object.js"
|
||||
import { globalVars } from "@/utils/constants.js"
|
||||
|
||||
let eventSrc = null
|
||||
@@ -179,6 +180,13 @@ async function eventRouter (eventType, message) {
|
||||
// Parse the JSON string before passing to updateSourceInfo
|
||||
try {
|
||||
const parsedMessage = JSON.parse(message)
|
||||
// SSE entries (ReducedIndex) never include scopeQuota. Keep the quota already loaded
|
||||
// from /api/settings/sources instead of letting the update clear it.
|
||||
for (const [name, entry] of Object.entries(parsedMessage)) {
|
||||
if (entry && typeof entry === 'object' && entry.scopeQuota === undefined) {
|
||||
entry.scopeQuota = getObjectProperty(state.sources.info, name)?.scopeQuota
|
||||
}
|
||||
}
|
||||
mutations.updateSourceInfo(parsedMessage)
|
||||
} catch (err) {
|
||||
console.error('Error parsing sourceUpdate message:', err, message)
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { stateMock } = vi.hoisted(() => ({
|
||||
stateMock: {
|
||||
sources: {
|
||||
hasSourceInfo: false,
|
||||
info: {
|
||||
data: {
|
||||
used: 0,
|
||||
total: 50 * 1024 ** 3,
|
||||
usedAlt: 0,
|
||||
totalRoot: 0,
|
||||
usedAltRoot: 0,
|
||||
usedPercentage: 0,
|
||||
status: "ready",
|
||||
name: "data",
|
||||
files: 0,
|
||||
folders: 0,
|
||||
lastIndex: 0,
|
||||
quickScanDurationSeconds: 0,
|
||||
fullScanDurationSeconds: 0,
|
||||
complexity: 0,
|
||||
scanners: [],
|
||||
readOnly: false,
|
||||
private: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
realtimeActive: undefined,
|
||||
realtimeDownCount: 0,
|
||||
user: { username: "alice" },
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("./state.ts", () => ({ state: stateMock }));
|
||||
vi.mock("./eventBus.ts", () => ({ emitStateChanged: vi.fn() }));
|
||||
vi.mock("@/api/viewToken.js", () => ({ setActiveViewGrantScope: vi.fn() }));
|
||||
vi.mock("@/api/index.js", () => ({ resourcesApi: {}, usersApi: {} }));
|
||||
vi.mock("@/api/settings.js", () => ({
|
||||
getEnforcedUserDefaults: vi.fn(),
|
||||
getShareDefaultsPolicy: vi.fn(),
|
||||
getSidebarLinkDefaultsPolicy: vi.fn(),
|
||||
getToolAccessDefaultsPolicy: vi.fn(),
|
||||
}));
|
||||
vi.mock("@/i18n/index.ts", () => ({ detectLocale: () => "en", setLocale: vi.fn() }));
|
||||
vi.mock("@/notify/index.ts", () => ({ notify: { show: vi.fn() } }));
|
||||
vi.mock("@/utils/index.ts", () => ({ url: {} }));
|
||||
vi.mock("@/utils/mimetype.js", () => ({ getTypeInfo: vi.fn() }));
|
||||
vi.mock("@/utils/object.js", async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
return actual;
|
||||
});
|
||||
vi.mock("@/utils/sort.ts", () => ({ sortedItems: vi.fn() }));
|
||||
vi.mock("@/utils/sidebarCategory.ts", () => ({ isSourceSidebarCategory: vi.fn() }));
|
||||
vi.mock("@/utils/pwaManifest.js", () => ({ updateManifestLink: vi.fn() }));
|
||||
vi.mock("@/utils/theme.js", () => ({ syncEventTheme: vi.fn() }));
|
||||
vi.mock("@/utils/uploadNavigationGuard.ts", () => ({
|
||||
cancelCloseUploadPrompt: vi.fn(),
|
||||
confirmCloseUploadPrompt: vi.fn(),
|
||||
hasCloseWithActiveUploadsPrompt: vi.fn(),
|
||||
}));
|
||||
vi.mock("./getters.ts", () => ({ getters: {} }));
|
||||
|
||||
import { mutations } from "./mutations.ts";
|
||||
|
||||
const SCOPE_LIMIT = 10 * 1024 * 1024;
|
||||
const SCOPE_USED = 2 * 1024 * 1024;
|
||||
|
||||
describe("mutations.updateSourceInfo scope quota", () => {
|
||||
beforeEach(() => {
|
||||
stateMock.sources.hasSourceInfo = false;
|
||||
stateMock.sources.info = {
|
||||
data: {
|
||||
used: 0,
|
||||
total: 50 * 1024 ** 3,
|
||||
usedAlt: 0,
|
||||
totalRoot: 0,
|
||||
usedAltRoot: 0,
|
||||
usedPercentage: 0,
|
||||
status: "ready",
|
||||
name: "data",
|
||||
files: 0,
|
||||
folders: 0,
|
||||
lastIndex: 0,
|
||||
quickScanDurationSeconds: 0,
|
||||
fullScanDurationSeconds: 0,
|
||||
complexity: 0,
|
||||
scanners: [],
|
||||
readOnly: false,
|
||||
private: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
it("merges scopeQuota from /api/settings/sources into store source info", () => {
|
||||
mutations.updateSourceInfo({
|
||||
data: {
|
||||
used: 100,
|
||||
total: 50 * 1024 ** 3,
|
||||
status: "ready",
|
||||
name: "data",
|
||||
scopeQuota: {
|
||||
quotaKind: "scope",
|
||||
limitBytes: SCOPE_LIMIT,
|
||||
usedBytes: SCOPE_USED,
|
||||
reservedBytes: 0,
|
||||
meter: "index_scope",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const info = stateMock.sources.info.data;
|
||||
expect(info.scopeQuota?.limitBytes).toBe(SCOPE_LIMIT);
|
||||
expect(info.scopeQuota?.usedBytes).toBe(SCOPE_USED);
|
||||
expect(info.total).toBe(50 * 1024 ** 3);
|
||||
expect(stateMock.sources.hasSourceInfo).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -252,9 +252,17 @@ export const mutations = {
|
||||
readOnly: source.readOnly || false,
|
||||
private: source.private || false,
|
||||
indexingDisabled: source.indexingDisabled || false,
|
||||
scopeQuota: source.scopeQuota,
|
||||
};
|
||||
info = setObjectProperty(info, k, updated) as Record<string, SourceInfo>;
|
||||
if (updated.total > 0 || updated.used > 0 || updated.usedAlt > 0) hasAny = true;
|
||||
if (
|
||||
updated.total > 0 ||
|
||||
updated.used > 0 ||
|
||||
updated.usedAlt > 0 ||
|
||||
(updated.scopeQuota?.limitBytes ?? 0) > 0
|
||||
) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
state.sources.info = info;
|
||||
@@ -319,12 +327,19 @@ export const mutations = {
|
||||
readOnly: prev ? prev.readOnly : false,
|
||||
private: prev ? prev.private : false,
|
||||
indexingDisabled: prev ? prev.indexingDisabled : false,
|
||||
scopeQuota: prev?.scopeQuota,
|
||||
};
|
||||
}
|
||||
// Sidebar usage bar uses hasSourceInfo + per-source used/total; must survive object replace
|
||||
sources.hasSourceInfo = user.scopes.some((s: UserScope) => {
|
||||
const e = sources.info[s.name];
|
||||
return e && (e.total > 0 || e.used > 0 || e.usedAlt > 0);
|
||||
return (
|
||||
e &&
|
||||
(e.total > 0 ||
|
||||
e.used > 0 ||
|
||||
e.usedAlt > 0 ||
|
||||
(e.scopeQuota?.limitBytes ?? 0) > 0)
|
||||
);
|
||||
});
|
||||
// Check if user has custom sidebar links with sources
|
||||
let targetSource = sources.current;
|
||||
|
||||
@@ -120,6 +120,18 @@ export interface Prompt {
|
||||
cancel?: unknown;
|
||||
}
|
||||
|
||||
/** Scope quota snapshot from GET /api/settings/sources (sidebar usage bar). */
|
||||
export interface ScopeQuotaInfo {
|
||||
quotaKind?: string;
|
||||
limitBytes: number;
|
||||
usedBytes?: number;
|
||||
reservedBytes?: number;
|
||||
meter?: string;
|
||||
configuredMeter?: string;
|
||||
effectiveMeter?: string;
|
||||
measurementStatus?: string;
|
||||
}
|
||||
|
||||
export interface SourceInfo {
|
||||
pathPrefix?: string | undefined;
|
||||
used: number;
|
||||
@@ -141,6 +153,7 @@ export interface SourceInfo {
|
||||
readOnly: boolean;
|
||||
private: boolean;
|
||||
indexingDisabled?: boolean | undefined;
|
||||
scopeQuota?: ScopeQuotaInfo | undefined;
|
||||
}
|
||||
|
||||
/** Raw shape of a single source entry as sent by /api/settings/sources or SSE updates. */
|
||||
@@ -163,6 +176,7 @@ export interface SourceInfoUpdate {
|
||||
readOnly?: boolean;
|
||||
private?: boolean;
|
||||
indexingDisabled?: boolean;
|
||||
scopeQuota?: ScopeQuotaInfo;
|
||||
}
|
||||
|
||||
export interface SourceFilePermissions {
|
||||
|
||||
Reference in new issue
Block a user