diff --git a/app/server/modules/volumes/volume.service.ts b/app/server/modules/volumes/volume.service.ts index 824ac4f5..401966d6 100644 --- a/app/server/modules/volumes/volume.service.ts +++ b/app/server/modules/volumes/volume.service.ts @@ -371,7 +371,7 @@ const listFiles = async ( offset: startOffset, limit: pageSize, total, - hasMore: startOffset + entries.length < total, + hasMore: startOffset + pageSize < total, }; } catch (error) { if (isNodeJSErrnoException(error) && error.code === "ENOENT") { diff --git a/app/server/utils/restic.ts b/app/server/utils/restic.ts index 2b5905ee..4f5b4874 100644 --- a/app/server/utils/restic.ts +++ b/app/server/utils/restic.ts @@ -725,10 +725,10 @@ const ls = async ( let isFirstLine = true; let hasMore = false; - const offset = options?.offset ?? 0; - const limit = options?.limit ?? 500; + const offset = Math.max(options?.offset ?? 0, 0); + const limit = Math.min(Math.max(options?.limit ?? 500, 1), 500); - await safeSpawn({ + const res = await safeSpawn({ command: "restic", args, env, @@ -770,6 +770,11 @@ const ls = async ( await cleanupTemporaryKeys(env); + if (res.exitCode !== 0) { + logger.error(`Restic ls failed: ${res.error}`); + throw new ResticError(res.exitCode, res.error); + } + if (totalNodes > offset + limit) { hasMore = true; }