Skip to content

Commit

Permalink
Merge pull request #15 from TaBayramNTT/develop
Browse files Browse the repository at this point in the history
v0.13.3
  • Loading branch information
TaBayramNTT authored Oct 31, 2023
2 parents a26423a + 411303d commit 95de0b3
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 61 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.13.3] - 31/10/2023

### Fixed

- Downloading remote folder would also download non-web directories.

## [0.13.2] - 30/10/2023

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"homepage": "https://github.com/TaBayramNTT/vscode-miisync",
"icon": "resources/icon.png",
"version": "0.13.2",
"version": "0.13.3",
"license": "MIT",
"engines": {
"vscode": "^1.83.1"
Expand Down
14 changes: 6 additions & 8 deletions resources/icon_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/miiservice/abstract/filters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MII, RowsetsFatal } from "./responsetypes";

export function IsFatalResponse(response): response is MII<null, null, RowsetsFatal> {
return response && 'FatalError' in response.Rowsets;
return response?.Rowsets && 'FatalError' in response.Rowsets;
}
5 changes: 3 additions & 2 deletions src/transfer/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ export async function StartAction(type: ActionType, { name, resource, system }:
logger.infoplus(system.name, name, GetStateMessage("Started", resource));
const { aborted, error, message } = await actionPromise();
if (error) {
statusBar.updateBar("Error", Icon.error, { duration: 2 });
statusBar.updateBar("Error", Icon.error, { duration: 3 });
logger.errorPlus(system.name, name, message || "");
}
else if (aborted) {
statusBar.updateBar("Cancelled", Icon.close, { duration: 2 });
statusBar.updateBar("Cancelled", Icon.close, { duration: 3 });
logger.infoplus(system.name, name, GetStateMessage("Cancelled", resource));
}
else {
statusBar.updateBar(texts.end, Icon.success, { duration: 2 });
logger.infoplus(system.name, name, GetStateMessage("Completed", resource));
}
} catch (error: any) {
statusBar.updateBar("Error", Icon.error, { duration: 3 });
logger.toastError(error);
}
}
Expand Down
27 changes: 16 additions & 11 deletions src/transfer/limited/deletecomplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ export async function DeleteComplexLimited(folder: SimpleFolder, userConfig: Use
let aborted = false;

const promises: Promise<any>[] = [];
limitManager.startProgress();
limitManager.createWindow('Deleting', () => aborted = true)
try {
limitManager.startProgress();
limitManager.createWindow('Deleting', () => aborted = true)

await deleteRecursive(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);
await deleteRecursive(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

limitManager.endProgress();
return {
aborted
};
limitManager.endProgress();
return {
aborted
};
} catch (error: any) {
limitManager.endProgress();
throw Error(error);
}

async function deleteRecursive(folder: SimpleFolder) {
if (aborted) return;
Expand Down
55 changes: 32 additions & 23 deletions src/transfer/limited/downloadcomplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,42 @@ export async function DownloadComplexLimited(folder: ComplexFolder, getPath: (it
return { aborted: true, };
}

limitManager.startProgress();
limitManager.createWindow('Preparing Download', () => aborted = true)
let fileCount = 0;
let promises: Promise<any>[] = [];
try {
limitManager.startProgress();
limitManager.createWindow('Preparing Download', () => aborted = true)

await getChildren(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

await getChildren(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

if (aborted) {
limitManager.endProgress();
return { aborted };
}
limitManager.createWindow('Downloading', () => aborted = true)
limitManager.MaxQueue = 0;
limitManager.Finished = 0;
promises = [];

await downloadFiles(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

if (aborted) {
limitManager.endProgress();

return { aborted };
} catch (error: any) {
limitManager.endProgress();
throw Error(error);
}
limitManager.createWindow('Downloading', () => aborted = true)
limitManager.MaxQueue = 0;
limitManager.Finished = 0;
promises = [];

await downloadFiles(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

limitManager.endProgress();

return { aborted };

async function getChildren(mainFolder: ComplexFolder) {
if (aborted) return;
Expand All @@ -81,7 +87,8 @@ export async function DownloadComplexLimited(folder: ComplexFolder, getPath: (it
const files = await listFilesService.call({ host: system.host, port: system.port }, mainFolder.folder.Path);
if (aborted) return;
if (!files || IsFatalResponse(files)) return;
mainFolder.files = files?.Rowsets?.Rowset?.Row?.map((cFile) => { return { file: cFile, path: null } }) || [];
mainFolder.files = files?.Rowsets?.Rowset?.Row?.
map((cFile) => { return { file: cFile, path: null } }) || [];

})
promises.push(filePromise);
Expand All @@ -92,7 +99,9 @@ export async function DownloadComplexLimited(folder: ComplexFolder, getPath: (it
const folders = await listFoldersService.call({ host: system.host, port: system.port }, mainFolder.folder.Path);
if (aborted) return;
if (!folders || IsFatalResponse(folders)) return;
mainFolder.folders = folders?.Rowsets?.Rowset?.Row?.map((cFolder) => { return { folder: cFolder, path: null, files: [], folders: [] } }) || [];
mainFolder.folders = folders?.Rowsets?.Rowset?.Row?.
filter((cFolder) => cFolder.IsWebDir).
map((cFolder) => { return { folder: cFolder, path: null, files: [], folders: [] } }) || [];

for (const folder of mainFolder.folders) {
promises.push(limitManager.newRemote(() => getChildren(folder)));
Expand Down
1 change: 1 addition & 0 deletions src/transfer/limited/limited.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import pLimit = require("p-limit");

export interface LimitedReturn<T> {
aborted: boolean,
error?: Error,
data?: T
}

Expand Down
32 changes: 17 additions & 15 deletions src/transfer/limited/uploadcomplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,24 @@ export async function UploadComplexLimited(folder: SimpleFolder, userConfig: Use
let aborted = false;

const promises: Promise<any>[] = [];
limitManager.startProgress();
limitManager.createWindow('Uploading', () => aborted = true)
try {
limitManager.startProgress();
limitManager.createWindow('Uploading', () => aborted = true)

await fillEmptyFolders(folder);
await uploadRecursive(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

limitManager.endProgress();
return { aborted };
} catch (error: any) {
limitManager.endProgress();
throw Error(error);
}

await fillEmptyFolders(folder);
async function fillEmptyFolders(mainFolder: SimpleFolder) {
const promises: Promise<any>[] = [];
for (const folder of mainFolder.folders) {
Expand All @@ -44,18 +58,6 @@ export async function UploadComplexLimited(folder: SimpleFolder, userConfig: Use
return 1;
}

await uploadRecursive(folder);
do {
await Promise.all(promises);
}
while (limitManager.OngoingCount != 0);

limitManager.endProgress();

return {
aborted
};

async function uploadRecursive(folder: SimpleFolder) {
if (aborted) return;
if (!await ValidatePath(folder.path, userConfig)) return;
Expand Down

0 comments on commit 95de0b3

Please sign in to comment.