Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.11.6 #10

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
system name in logs,
  • Loading branch information
TaBayramNTT committed Sep 14, 2023
commit b33a636e8c52ceea0896126364abf15718dfd506
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [0.11.6] - 13/09/2023

### Added

- `Transfer File` explorer command.
- Default '*.' ignore case.
- System name to most logs.

### Fixed

- Deleting files wouldn't clear the cache.


## [0.11.5] - 28/07/2023

### Changed
Expand Down
13 changes: 12 additions & 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.11.5",
"version": "0.11.6",
"license": "MIT",
"engines": {
"vscode": "^1.77.0"
Expand Down Expand Up @@ -84,6 +84,12 @@
"category": "mii",
"enablement": "miisync.enabled && miisync.loggedin"
},
{
"command": "miisync.transferfile",
"title": "Transfer File",
"category": "zmii",
"enablement": "miisync.enabled && miisync.loggedin"
},
{
"command": "miisync.deletefile",
"title": "Delete Current File",
Expand Down Expand Up @@ -267,6 +273,11 @@
"group": "miisync.file@3",
"when": "miisync.enabled && !explorerResourceIsRoot && !explorerResourceIsFolder"
},
{
"command": "miisync.transferfile",
"group": "miisync.file@4",
"when": "miisync.enabled && !explorerResourceIsRoot && !explorerResourceIsFolder"
},
{
"command": "miisync.deletefile",
"group": "miisync.file@5",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/commandgitchanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export async function OnCommandUploadGitChanges() {
const files = changes.filter((change) => (change.status != Status.DELETED && change?.uri)).map(change => change.uri);

statusBar.updateBar('Uploading', Icon.spinLoading, { duration: -1 });
logger.infos("Upload Git Changes", "Changes:" + files.length + " Started");
logger.infoplus(configManager.CurrentSystem.name,"Upload Git Changes", "Changes:" + files.length + " Started");

//todo: try to prevent possible duplicate bug
const response = await UploadFilesLimited(files, userConfig, configManager.CurrentSystem);

if(response.aborted){
statusBar.updateBar('Cancelled', Icon.success, { duration: 1 });
logger.infos("Upload Git Changes", "Cancelled");
logger.infoplus(configManager.CurrentSystem.name,"Upload Git Changes", "Cancelled");
}
else{
statusBar.updateBar('Uploaded', Icon.success, { duration: 1 });
logger.infos("Upload Git Changes", "Completed");
logger.infoplus(configManager.CurrentSystem.name,"Upload Git Changes", "Completed");
}
}
14 changes: 14 additions & 0 deletions src/commands/commandtransferfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Uri } from "vscode";
import { configManager } from "../modules/config";
import { TransferFile } from "../transfer/transfer";


export async function OnCommandTransferFile(uri: Uri) {
const userConfig = await configManager.load();
if (!userConfig) return;

if (uri) {
TransferFile(uri, userConfig);
return;
}
}
2 changes: 1 addition & 1 deletion src/events/changeactivettexteditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function CheckFileDifference(document: vscode.TextDocument, fileProp: File
if (response === 1) {
await writeFile(document.fileName, Buffer.from(payload.Value, 'base64'), { encoding: "utf8" });
statusBar.updateBar("Downloaded " + path.basename(document.fileName), Icon.success, { duration: 3 });
logger.infos('Download File', path.basename(document.fileName) + ": Finished.");
logger.infoplus(system.name,'Download File', path.basename(document.fileName) + ": Finished.");
}
else if (response === 2) {
const extension = path.extname(document.fileName).substring(1);
Expand Down
2 changes: 2 additions & 0 deletions src/extension/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OnCommandOpenRootConfig } from '../commands/commandopenrootconfig';
import { OnCommandOpenScreen } from '../commands/commandopenscreen';
import { OnCommandLogin, OnCommandLogout, OnCommandSwitchSystem } from '../commands/commandsession';
import { OnCommandDisableDownloadOnOpen, OnCommandDisableSyncSave, OnCommandEnableDownloadOnOpen, OnCommandEnableSyncSave } from '../commands/commandtogglesync';
import { OnCommandTransferFile } from '../commands/commandtransferfile';
import { OnCommandTransferFolder } from '../commands/commandtransferfolder';
import { OnCommandUploadFile } from '../commands/commanduploadfile';
import { OnCommandUploadFolder } from '../commands/commanduploadfolder';
Expand Down Expand Up @@ -50,6 +51,7 @@ export function RegisterCommands(context: vscode.ExtensionContext) {
RegisterCommand('miisync.downloadfileproperties', OnCommandDownloadFileProperties, context);
RegisterCommand('miisync.uploadfolder', OnCommandUploadFolder, context);
RegisterCommand('miisync.transferfolder', OnCommandTransferFolder, context);
RegisterCommand('miisync.transferfile', OnCommandTransferFile, context);
RegisterCommand('miisync.disabledownloadonopen', OnCommandDisableDownloadOnOpen, context);
RegisterCommand('miisync.enabledownloadonopen', OnCommandEnableDownloadOnOpen, context);
RegisterCommand('miisync.deletefile', OnCommandDeleteFile, context);
Expand Down
26 changes: 26 additions & 0 deletions src/miiservice/blowoutservice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Request, Service } from './abstract/miiservice.js';
import { MII, RowsetsMessage } from './abstract/responsetypes.js';

class BlowoutService extends Service {
name: string = "Delete Batch";
mode: string = "XMII/Catalog?Mode=Blowout&Class=Content&Content-Type=text/xml";

async call({ host, port }: Request, folderPath: string) {
const url = this.get(host, port, folderPath);
const { value, error, isError } = await this.fetch(new URL(url));
let data: MII<null, null, RowsetsMessage> = null;
if (!isError) {
data = this.parseXML(value);
}
return data;
}
get(host: string, port: number, sourcePath: string) {
return this.generateURL(host, port, "http") + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
}
protected generateParams(folder: string) {
return "Folder=" + folder;
}
}


export const blowoutService = new BlowoutService();
2 changes: 1 addition & 1 deletion src/modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function GetWorkspaceConfig(): UserConfig {
remotePath: conf.get("remotePath", 'MES'),
downloadOnOpen: false,
uploadOnSave: false,
ignore: conf.get('ignore', ['package.json']),
ignore: conf.get('ignore', ['package.json', '.*']),
include: conf.get('include', []),
useRootConfig: conf.get('useRootConfig', false),
rootConfig: conf.get('rootConfig', '')
Expand Down
20 changes: 10 additions & 10 deletions src/transfer/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function DownloadFile(uri: Uri, userConfig: UserConfig, system: Sys
await writeFile(filePath, Buffer.from(payload.Value, 'base64'), { encoding: "utf8" })

statusBar.updateBar("Downloaded " + fileName, Icon.success, { duration: 3 });
logger.infos('Download File', fileName + ": Finished.");
logger.infoplus(system.name,'Download File', fileName + ": Finished.");
}


Expand All @@ -46,7 +46,7 @@ export async function DownloadFolder(folderUri: Uri | string, userConfig: UserCo
return false;
}
statusBar.updateBar('Downloading', Icon.spinLoading, { duration: -1 });
logger.infos("Download Folder", path.basename(folderPath) + ": Started");
logger.infoplus(system.name,"Download Folder", path.basename(folderPath) + ": Started");

function getPath(item: File | Folder) {
if ('FolderName' in item) {
Expand All @@ -65,11 +65,11 @@ export async function DownloadFolder(folderUri: Uri | string, userConfig: UserCo

if(response.aborted){
statusBar.updateBar('Cancelled', Icon.success, { duration: 1 });
logger.infos("Download Folder", path.basename(folderPath) + ": Cancelled");
logger.infoplus(system.name,"Download Folder", path.basename(folderPath) + ": Cancelled");
}
else{
statusBar.updateBar('Downloaded', Icon.success, { duration: 1 });
logger.infos("Download Folder", path.basename(folderPath) + ": Completed");
logger.infoplus(system.name,"Download Folder", path.basename(folderPath) + ": Completed");
}
}

Expand Down Expand Up @@ -97,7 +97,7 @@ export async function DownloadRemoteFolder(remoteFolderPath: string, userConfig:

const folderName = path.basename(remoteFolderPath);
statusBar.updateBar('Downloading', Icon.spinLoading, { duration: -1 });
logger.infos("Download Remote Folder", folderName + ": Started");
logger.infoplus(system.name,"Download Remote Folder", folderName + ": Started");
const workspaceFolder = GetCurrentWorkspaceFolder().fsPath;

function getPath(item: File | Folder) {
Expand All @@ -116,11 +116,11 @@ export async function DownloadRemoteFolder(remoteFolderPath: string, userConfig:

if(response.aborted){
statusBar.updateBar('Cancelled', Icon.success, { duration: 1 });
logger.infos("Download Remote Folder", folderName + ": Cancelled");
logger.infoplus(system.name,"Download Remote Folder", folderName + ": Cancelled");
}
else{
statusBar.updateBar('Downloaded', Icon.success, { duration: 1 });
logger.infos("Download Remote Folder", folderName + ": Completed");
logger.infoplus(system.name,"Download Remote Folder", folderName + ": Completed");
}


Expand All @@ -145,7 +145,7 @@ export async function DownloadRemoteFile({ filePath, name }: { filePath: string,
}

statusBar.updateBar('Downloaded', Icon.success, { duration: 1 });
logger.infos('Download Remote File', name + ": Finished.");
logger.infoplus(system.name,'Download Remote File', name + ": Finished.");
}

export async function DownloadContextDirectory(userConfig: UserConfig, system: System) {
Expand All @@ -156,12 +156,12 @@ export async function DownloadContextDirectory(userConfig: UserConfig, system: S
const parentPath = path.dirname(sourcePath).replaceAll(path.sep, "/");

statusBar.updateBar('Downloading', Icon.spinLoading, { duration: -1 });
logger.infos("Download Context Directory", sourcePath + ": Started");
logger.infoplus(system.name,"Download Context Directory", sourcePath + ": Started");

const files = await loadFilesInsideService.call({ host: system.host, port: system.port }, sourcePath);
remoteDirectoryTree.generateItemsByFiles(files?.Rowsets?.Rowset?.Row);
statusBar.updateBar('Downloaded', Icon.success, { duration: 2 });
logger.infos("Download Context Directory", sourcePath + ": Completed");
logger.infoplus(system.name,"Download Context Directory", sourcePath + ": Completed");
}

//---------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions src/transfer/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { Uri } from "vscode";
import { System } from "../extension/system";
import { blowoutService } from "../miiservice/blowoutservice";
import { deleteBatchService } from "../miiservice/deletebatchservice";
import { readFilePropertiesService } from "../miiservice/readfilepropertiesservice";
import { UserConfig } from "../modules/config";
Expand Down Expand Up @@ -33,7 +34,8 @@ export async function DeleteFile(uri: Uri, userConfig: UserConfig, system: Syste
const response = await deleteBatchService.call({ host: system.host, port: system.port }, sourcePath);
if (response) {
const fileName = path.basename(sourcePath);
logger.infos("Delete File", fileName + ": " + response?.Rowsets?.Messages?.Message);
logger.infoplus(system.name,"Delete File", fileName + ": " + response?.Rowsets?.Messages?.Message);
await blowoutService.call({host: system.host, port: system.port}, sourcePath);
}
statusBar.updateBar('Deleted', Icon.success, { duration: 1 })

Expand All @@ -56,7 +58,8 @@ export async function DeleteFolder(uri: Uri, userConfig: UserConfig, system: Sys
const response = await deleteBatchService.call({ host: system.host, port: system.port }, sourcePath);
if (response) {
const folderName = path.basename(sourcePath);
logger.infos("Delete Folder", folderName + ": " + response?.Rowsets?.Messages?.Message);
logger.infoplus(system.name,"Delete Folder", folderName + ": " + response?.Rowsets?.Messages?.Message);
await blowoutService.call({host: system.host, port: system.port}, sourcePath);
}
statusBar.updateBar('Deleted', Icon.success, { duration: 1 })

Expand Down
28 changes: 25 additions & 3 deletions src/transfer/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFile } from "fs-extra";
import { Uri } from "vscode";
import { System } from "../extension/system";
import { UserConfig, configManager } from "../modules/config";
Expand All @@ -7,6 +8,7 @@ import { QuickPickItem } from "../ui/quickpick";
import statusBar, { Icon } from "../ui/statusbar";
import { GetUserManager } from "../user/usermanager";
import { UploadFolderLimited } from "./limited/upload";
import { UploadFile } from "./upload";
import path = require("path");


Expand All @@ -25,18 +27,38 @@ export async function TransferFolder(uri: Uri, userConfig: UserConfig) {
if (!await user.login()) return;

statusBar.updateBar('Transfering', Icon.spinLoading, { duration: -1 });
logger.infos("Transfer Folder", path.basename(uri.fsPath) + ": Started");
logger.infoplus(configManager.CurrentSystem.name, "Transfer Folder", "->" + system.name + ', ' + path.basename(uri.fsPath) + ": Started");

const response = await UploadFolderLimited(uri.fsPath, userConfig, system);

if (response.aborted) {
statusBar.updateBar('Cancelled', Icon.success, { duration: 1 });
logger.infos("Transfer Folder", path.basename(uri.fsPath) + ": Cancelled");
logger.infoplus(configManager.CurrentSystem.name, "Transfer Folder", "->" + system.name + ', ' + path.basename(uri.fsPath) + ": Cancelled");
}
else {
statusBar.updateBar('Transferred', Icon.success, { duration: 1 });
logger.infos("Transfer Folder", path.basename(uri.fsPath) + ": Completed");
logger.infoplus(configManager.CurrentSystem.name, "Transfer Folder", "->" + system.name + ', ' + path.basename(uri.fsPath) + ": Completed");
}
}

}

export async function TransferFile(uri: Uri, userConfig: UserConfig) {
let picks: QuickPickItem<System>[] = [];
for (const system of userConfig.systems) {
if (configManager.CurrentSystem != system) {
picks.push({ label: system.name, description: system.host + ':' + system.port, object: system })
}
}

const quickResponse: QuickPickItem<System> = await ShowQuickPick(picks, { title: 'Pick System' });
if (quickResponse) {
const system = quickResponse.object;
const user = GetUserManager(system, true);
if (!await user.login()) return;

const content = (await readFile(uri.fsPath)).toString('utf-8');
const response = await UploadFile(uri, content, userConfig, system);
}

}
8 changes: 4 additions & 4 deletions src/transfer/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function UploadFile(uri: Uri, content: string, userConfig: UserConf
statusBar.updateBar('Uploading', Icon.spinLoading, { duration: -1 });
const response = await saveFileService.call({ host: system.host, port: system.port, body: "Content=" + base64Content }, sourcePath);
if (response) {
logger.infos("Upload File", fileName + ": " + response?.Rowsets?.Messages?.Message);
logger.infoplus(system.name,"Upload File", fileName + ": " + response?.Rowsets?.Messages?.Message);
}
statusBar.updateBar("Uploaded " + fileName, Icon.success, { duration: 3 });
}
Expand All @@ -49,17 +49,17 @@ export async function UploadFolder(folderUri: Uri | string, userConfig: UserConf
return;
}
statusBar.updateBar('Uploading', Icon.spinLoading, { duration: -1 });
logger.infos("Upload Folder", folderName + ": Started");
logger.infoplus(system.name,"Upload Folder", folderName + ": Started");

const response = await UploadFolderLimited(folderPath, userConfig, system);

if (response.aborted) {
statusBar.updateBar('Cancelled', Icon.success, { duration: 1 });
logger.infos("Upload Folder", folderName + ": Cancelled");
logger.infoplus(system.name,"Upload Folder", folderName + ": Cancelled");
}
else {
statusBar.updateBar('Uploaded', Icon.success, { duration: 1 });
logger.infos("Upload Folder", folderName + ": Completed");
logger.infoplus(system.name,"Upload Folder", folderName + ": Completed");
}


Expand Down
4 changes: 2 additions & 2 deletions src/ui/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export class Logger implements ILogger {
this.log('[fail]', message, ...args);
}

infos(source: string, message: string, ...args: any[]) {
this.log('[info]', "(" + source + ")", message, ...args);
infoplus(systemName: string, source: string, message: string, ...args: any[]) {
this.log('[info]','<'+systemName+'>', "(" + source + ")", message, ...args);
}

toastError(message: string | Error, ...args: any[]) {
Expand Down