///
import type Sync from "../sync";
import { type CloudItemTree, type FSItemType } from "@filen/sdk";
import { Semaphore } from "../../semaphore";
import fs from "fs-extra";
import { type DistributiveOmit, type Prettify } from "../../types";
export type RemoteItemBase = Prettify & {
path: string;
}>;
export type RemoteItem = (RemoteItemBase & {
type: "file";
}) | (Prettify> & {
type: "directory";
});
export type RemoteDirectoryTree = Record;
export type RemoteDirectoryUUIDs = Record;
export type RemoteTree = {
tree: RemoteDirectoryTree;
uuids: RemoteDirectoryUUIDs;
size: number;
};
export type RemoteTreeIgnoredReason = "dotFile" | "invalidPath" | "filenIgnore" | "pathLength" | "nameLength" | "defaultIgnore" | "empty" | "duplicate";
export type RemoteTreeIgnored = {
localPath: string;
relativePath: string;
reason: RemoteTreeIgnoredReason;
};
export declare const DEVICE_ID_VERSION = 1;
export declare class RemoteFileSystem {
private readonly sync;
getDirectoryTreeCache: {
timestamp: number;
tree: RemoteDirectoryTree;
uuids: RemoteDirectoryUUIDs;
ignored: RemoteTreeIgnored[];
size: number;
};
private readonly mutex;
private readonly mkdirMutex;
readonly itemsMutex: Semaphore;
readonly listSemaphore: Semaphore;
private deviceIdCache;
ignoredCache: Map;
constructor(sync: Sync);
getDeviceId(): Promise;
clearDeviceId(): Promise;
isPathIgnored({ absolutePath, relativePath, name, type }: {
absolutePath: string;
relativePath: string;
name: string;
type: "file" | "directory";
}): {
ignored: true;
reason: RemoteTreeIgnoredReason;
} | {
ignored: false;
};
getDirectoryTree(skipCache?: boolean): Promise<{
result: RemoteTree;
ignored: RemoteTreeIgnored[];
changed: boolean;
}>;
/**
* Find the corresponding UUID of the relative path.
* @date 3/3/2024 - 6:55:53 PM
*
* @public
* @async
* @param {{ relativePath: string; type?: FSItemType }} param0
* @param {string} param0.relativePath
* @param {FSItemType} param0.type
* @returns {Promise}
*/
pathToItemUUID({ relativePath, type }: {
relativePath: string;
type?: FSItemType;
}): Promise;
/**
* Create a directory inside the remote sync path. Recursively creates intermediate directories if needed.
* @date 3/2/2024 - 9:34:14 PM
*
* @public
* @async
* @param {{ relativePath: string }} param0
* @param {string} param0.relativePath
* @returns {Promise}
*/
mkdir({ relativePath }: {
relativePath: string;
}): Promise;
/**
* Delete a file/directory inside the remote sync path.
* @date 3/3/2024 - 7:03:18 PM
*
* @public
* @async
* @param {{ relativePath: string; type?: FSItemType; permanent?: boolean }} param0
* @param {string} param0.relativePath
* @param {FSItemType} param0.type
* @param {boolean} [param0.permanent=false]
* @returns {Promise}
*/
unlink({ relativePath, type, permanent }: {
relativePath: string;
type?: FSItemType;
permanent?: boolean;
}): Promise;
/**
* Rename/Move a file/directory inside the remote sync path. Recursively creates intermediate directories if needed.
* @date 3/2/2024 - 9:35:12 PM
*
* @public
* @async
* @param {{ fromRelativePath: string; toRelativePath: string }} param0
* @param {string} param0.fromRelativePath
* @param {string} param0.toRelativePath
* @returns {Promise}
*/
rename({ fromRelativePath, toRelativePath }: {
fromRelativePath: string;
toRelativePath: string;
}): Promise;
/**
* Download a remote file.
* @date 3/2/2024 - 9:41:59 PM
*
* @public
* @async
* @param {{ relativePath: string }} param0
* @param {string} param0.relativePath
* @returns {Promise}
*/
download({ relativePath }: {
relativePath: string;
}): Promise;
remoteDirPathExisting(): Promise;
directoryExists(relativePath: string): Promise;
fileExists(relativePath: string): Promise;
}
export default RemoteFileSystem;