Skip to content

Commit bddaa3a

Browse files
authored
Merge pull request #1478 from internxt/coderabbitai/docstrings/d5f671c
πŸ“ Add docstrings to `fix/modification-time-for-file-and-folders`
2 parents abb6ce3 + 20542e4 commit bddaa3a

10 files changed

Lines changed: 65 additions & 0 deletions

File tree

β€Žsrc/backend/features/remote-sync/file-explorer/check-if-modified.tsβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ type Props = {
1313
isFirstExecution: boolean;
1414
};
1515

16+
/**
17+
* Synchronizes a local file with its remote Drive counterpart when their recorded sizes differ.
18+
*
19+
* On the first execution, local changes are uploaded when the file is fully hydrated. Remote changes
20+
* update the local placeholder and pin state.
21+
*
22+
* @param isFirstExecution - Whether this is the initial synchronization check for the file.
23+
*/
1624
export async function checkIfModified({ ctx, remote, local, isFirstExecution }: Props) {
1725
const path = remote.absolutePath;
1826

β€Žsrc/backend/features/remote-sync/file-explorer/update-file-placeholder.tsβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ type Props = {
1414
isFirstExecution: boolean;
1515
};
1616

17+
/**
18+
* Synchronizes a local Windows file placeholder with its remote file metadata and state.
19+
*
20+
* @param remote - The remote file to synchronize.
21+
* @param files - Local files indexed by remote UUID.
22+
* @param isFirstExecution - Whether this is the first synchronization after startup.
23+
*/
1724
export async function updateFilePlaceholder({ ctx, remote, files, isFirstExecution }: Props) {
1825
const path = remote.absolutePath;
1926
const { size } = remote;

β€Žsrc/backend/features/remote-sync/file-explorer/update-folder-placeholder.tsβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ type Props = {
1111
folders: FileExplorerFolders;
1212
};
1313

14+
/**
15+
* Updates the local placeholder for a remote folder.
16+
*
17+
* @param remote - The remote folder whose placeholder should be updated
18+
* @param folders - The local folders indexed by remote UUID
19+
* @returns `true` if the placeholder is created or updated, `false` if the remote name is invalid or an error occurs
20+
*/
1421
export async function updateFolderPlaceholder({ ctx, remote, folders }: Props) {
1522
const path = remote.absolutePath;
1623

β€Žsrc/backend/features/sync/actions/services/create-folder.tsβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ type Props = {
1212
parentUuid: FolderUuid;
1313
};
1414

15+
/**
16+
* Creates a remote folder for a local path and records its synchronization state.
17+
*
18+
* @param path - The local folder path to create remotely
19+
* @param parentUuid - The UUID of the remote parent folder
20+
* @returns The result of persisting the created or existing folder, or `undefined` when the operation is aborted or fails
21+
*/
1522
export async function createFolder({ ctx, path, parentUuid }: Props) {
1623
const name = basename(path);
1724
const { birthtime, mtime } = await FileSystemModule.statThrow({ absolutePath: path });

β€Žsrc/infra/sqlite/services/file/create-or-update-batch.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ type Props = {
1010
files: DriveFile[];
1111
};
1212

13+
/**
14+
* Creates or updates file records in the database in batches.
15+
*
16+
* @param files - The file records to create or update
17+
* @returns A `SqliteError` if the operation fails; otherwise, `undefined`.
18+
*/
1319
export async function createOrUpdateBatch({ files }: Props) {
1420
if (files.length === 0) return;
1521

β€Žsrc/infra/sqlite/services/file/create-or-update.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ type Props = {
88
file: DriveFile;
99
};
1010

11+
/**
12+
* Creates or updates a stored file record.
13+
*
14+
* @param file - The file record to persist
15+
* @returns The parsed file data, or `undefined` if persistence or parsing fails
16+
*/
1117
export function createOrUpdate({ file }: Props) {
1218
try {
1319
db.prepare(upsertQuery).run({

β€Žsrc/infra/sqlite/services/file/parse-data.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ type TProps = {
55
data: DriveFile;
66
};
77

8+
/**
9+
* Converts drive file data into a normalized simple drive file.
10+
*
11+
* @param data - The source drive file data
12+
* @returns The normalized drive file
13+
*/
814
export function parseData({ data }: TProps): SimpleDriveFile {
915
let name = data.plainName;
1016
if (data.type) name += `.${data.type}`;

β€Žsrc/infra/sqlite/services/folder/create-or-update-batch.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ type Props = {
1010
folders: DriveFolder[];
1111
};
1212

13+
/**
14+
* Creates or updates folder records in the database in batches.
15+
*
16+
* @param folders - The folder records to create or update
17+
* @returns `undefined` when processing succeeds, or a `SqliteError` when processing fails
18+
*/
1319
export async function createOrUpdateBatch({ folders }: Props) {
1420
if (folders.length === 0) return;
1521

β€Žsrc/infra/sqlite/services/folder/create-or-update.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ type Props = {
88
folder: DriveFolder;
99
};
1010

11+
/**
12+
* Creates or updates a folder record and returns its parsed representation.
13+
*
14+
* @param folder - The folder to persist.
15+
* @returns The parsed folder, or `undefined` if persistence or parsing fails.
16+
*/
1117
export function createOrUpdate({ folder }: Props) {
1218
try {
1319
db.prepare(upsertQuery).run({

β€Žsrc/infra/sqlite/services/folder/parse-data.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ type TProps = {
55
data: DriveFolder;
66
};
77

8+
/**
9+
* Converts drive folder data into a simplified folder representation.
10+
*
11+
* @param data - The drive folder data to convert
12+
* @returns A simplified drive folder containing its identifiers, metadata, timestamps, and status
13+
*/
814
export function parseData({ data }: TProps): SimpleDriveFolder {
915
return {
1016
uuid: data.uuid as FolderUuid,

0 commit comments

Comments
Β (0)