Fix git/storage workflows: repos-only page, default dev branch, robust pull/push, and storage path resolution
This commit is contained in:
@@ -32,12 +32,35 @@
|
||||
let isLoading = false;
|
||||
let currentPath = '';
|
||||
let uploadCategory = 'backups';
|
||||
let uploadSubpath = '';
|
||||
|
||||
// [DEF:resolveStorageQueryFromPath:Function]
|
||||
/**
|
||||
* @purpose Splits UI path into storage API category and category-local subpath.
|
||||
* @pre uiPath may be empty or start with backups/repositorys.
|
||||
* @post Returns {category, subpath} compatible with /api/storage/files.
|
||||
*/
|
||||
function resolveStorageQueryFromPath(uiPath: string): { category?: string; subpath?: string } {
|
||||
const segments = String(uiPath || '').split('/').filter(Boolean);
|
||||
if (segments.length === 0) return {};
|
||||
const topLevel = segments[0];
|
||||
if (topLevel !== 'backups' && topLevel !== 'repositorys') {
|
||||
return {};
|
||||
}
|
||||
const subpath = segments.slice(1).join('/');
|
||||
return {
|
||||
category: topLevel,
|
||||
subpath: subpath || undefined,
|
||||
};
|
||||
}
|
||||
// [/DEF:resolveStorageQueryFromPath:Function]
|
||||
|
||||
async function loadFiles() {
|
||||
console.log('[STORAGE-PAGE][LOAD_START] path=%s', currentPath);
|
||||
isLoading = true;
|
||||
try {
|
||||
files = await listFiles(undefined, currentPath);
|
||||
const query = resolveStorageQueryFromPath(currentPath);
|
||||
files = await listFiles(query.category, query.subpath);
|
||||
console.log('[STORAGE-PAGE][LOAD_OK] count=%d', files.length);
|
||||
} catch (error) {
|
||||
console.log('[STORAGE-PAGE][LOAD_ERR] error=%s', error.message);
|
||||
@@ -108,8 +131,11 @@
|
||||
* @post uploadCategory is either backups or repositorys.
|
||||
*/
|
||||
function updateUploadCategory() {
|
||||
const [topLevel] = currentPath.split('/').filter(Boolean);
|
||||
const [topLevel, ...rest] = currentPath.split('/').filter(Boolean);
|
||||
uploadCategory = topLevel === 'repositorys' ? 'repositorys' : 'backups';
|
||||
uploadSubpath = topLevel === 'repositorys' || topLevel === 'backups'
|
||||
? rest.join('/')
|
||||
: '';
|
||||
}
|
||||
// [/DEF:updateUploadCategory:Function]
|
||||
|
||||
@@ -180,7 +206,7 @@
|
||||
<div class="lg:col-span-1">
|
||||
<FileUpload
|
||||
category={uploadCategory}
|
||||
path={currentPath}
|
||||
path={uploadSubpath}
|
||||
on:uploaded={loadFiles}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user