fix: rclone pretry and unnecessary escapes

This commit is contained in:
Eli Bosley
2025-05-23 11:05:32 -04:00
parent 744f34fc7b
commit 8f8352090c
3 changed files with 19 additions and 9 deletions

View File

@@ -0,0 +1,3 @@
{
"demo": "hello.unraider"
}

View File

@@ -67,7 +67,7 @@ function translateRCloneOptionToJsonSchema({
case 'sizesuffix':
// Pattern allows 'off' or digits followed by optional size units (K, M, G, T, P) and optional iB/B
// Allows multiple concatenated values like 1G100M
schema.pattern = '^(off|(d+([KMGTPE]i?B?)?)+)$';
schema.pattern = '^(off|(\\d+([KMGTPE]i?B?)?)+)$';
schema.errorMessage = 'Invalid size format. Examples: "10G", "100M", "1.5GiB", "off".';
break;
case 'duration':

View File

@@ -6,6 +6,7 @@ import { dirname, join } from 'node:path';
import { execa } from 'execa';
import got, { HTTPError } from 'got';
import pRetry from 'p-retry';
import {
RCloneProviderOptionResponse,
@@ -122,14 +123,20 @@ export class RCloneApiService implements OnModuleInit, OnModuleDestroy {
this.isInitialized = false;
});
// Consider the service initialized shortly after starting the process
// A better approach might involve checking the socket or API readiness
await new Promise((resolve) => setTimeout(resolve, 1000)); // Small delay
// Re-check if socket is running after attempting start
const isRunning = await this.checkRcloneSocketRunning();
if (!isRunning) {
throw new Error('Rclone socket failed to start or become responsive.');
}
// Wait for socket to be ready using p-retry with exponential backoff
await pRetry(
async () => {
const isRunning = await this.checkRcloneSocketRunning();
if (!isRunning) throw new Error('Rclone socket not ready');
},
{
retries: 6, // 7 attempts total
minTimeout: 100,
maxTimeout: 5000,
factor: 2,
maxRetryTime: 30000,
}
);
return true;
} catch (error: unknown) {