fix: show local-repo files in the cached-objects UI
Local repos store uploaded files in the local_files table, while
remote/proxy repos cache into the artifacts table. The shared "Cached
Objects" page always queried the artifacts table via
/api/v2/remotes/{name}/objects, so local packages (e.g. an uploaded RPM)
were servable but listed as "0 objects" in the UI.
- add ListLocalArtifacts, joining local_files with blobs and returning
models.Artifact-shaped rows (size from the blob; counters zero and
timestamps derived from created_at, since local files track no access)
- add LocalRoutes to the objects handler: listLocal reads local_files,
evictLocal deletes via DeleteLocalFile; extract shared page parsing
into pageBounds
- mount /api/v2/locals/{name}/objects (GET + DELETE) in the server
- add listLocalObjects/evictLocalObject to the UI client and route the
Objects page to them when viewing a local repo
- cover the listing and eviction paths with a dockerised test
This commit is contained in:
@@ -34,6 +34,12 @@ export const api = {
|
||||
evictObject: (remote: string, path: string) =>
|
||||
fetchJSON<void>(`/api/v2/remotes/${remote}/objects/${path}`, { method: 'DELETE' }),
|
||||
|
||||
listLocalObjects: (name: string, page = 1, perPage = 50) =>
|
||||
fetchJSON<Artifact[]>(`/api/v2/locals/${name}/objects?page=${page}&per_page=${perPage}`),
|
||||
|
||||
evictLocalObject: (name: string, path: string) =>
|
||||
fetchJSON<void>(`/api/v2/locals/${name}/objects/${path}`, { method: 'DELETE' }),
|
||||
|
||||
flushRemoteCache: (remote: string) =>
|
||||
fetchJSON<void>(`/api/v2/remotes/${remote}/cache`, { method: 'DELETE' }),
|
||||
|
||||
|
||||
@@ -182,16 +182,17 @@ export function Objects() {
|
||||
const load = useCallback(() => {
|
||||
if (!name) return;
|
||||
setLoading(true);
|
||||
api.listObjects(name, 1, 5000)
|
||||
const req = isLocal ? api.listLocalObjects(name, 1, 5000) : api.listObjects(name, 1, 5000);
|
||||
req
|
||||
.then(a => setArtifacts(a || []))
|
||||
.finally(() => setLoading(false));
|
||||
}, [name]);
|
||||
}, [name, isLocal]);
|
||||
|
||||
useEffect(() => { load(); }, [load]);
|
||||
|
||||
const handleEvict = async (path: string) => {
|
||||
if (!name || !confirm(`Evict ${path}?`)) return;
|
||||
await api.evictObject(name, path);
|
||||
await (isLocal ? api.evictLocalObject(name, path) : api.evictObject(name, path));
|
||||
load();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user