Rename to miniSCP; migrate legacy data dirs on boot
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import type { Readable } from "node:stream";
|
||||
import { BRANDING } from "../../shared/branding";
|
||||
import type { EntryType, TransferSnapshot, TransferState } from "../../shared/types";
|
||||
import type { FileSystemProvider } from "../fs/provider";
|
||||
import type { SessionRegistry } from "../fs/registry";
|
||||
import { walkTree } from "./walk";
|
||||
|
||||
const PROGRESS_INTERVAL_MS = 100;
|
||||
// same-fs probe temp files stay attributable to the app that wrote them
|
||||
const PROBE_PREFIX = `.${BRANDING.appName.toLowerCase()}-probe-`;
|
||||
// workers per job; the shared slot budget is the real limit
|
||||
const MAX_WORKERS_PER_JOB = 8;
|
||||
|
||||
@@ -359,7 +362,8 @@ export class TransferEngine {
|
||||
dir: string,
|
||||
): Promise<boolean> {
|
||||
const token = crypto.randomUUID();
|
||||
const probePath = dst.join(dir, `.bunscp-probe-${token.slice(0, 8)}`);
|
||||
const probeName = `${PROBE_PREFIX}${token.slice(0, 8)}`;
|
||||
const probePath = dst.join(dir, probeName);
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const stream = dst.createWriteStream(probePath);
|
||||
@@ -368,7 +372,7 @@ export class TransferEngine {
|
||||
});
|
||||
try {
|
||||
const chunks: Buffer[] = [];
|
||||
for await (const chunk of src.createReadStream(src.join(dir, `.bunscp-probe-${token.slice(0, 8)}`))) {
|
||||
for await (const chunk of src.createReadStream(src.join(dir, probeName))) {
|
||||
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
||||
}
|
||||
const seen = Buffer.concat(chunks).toString("utf8") === token;
|
||||
|
||||
Reference in New Issue
Block a user