Skip to content

Commit

Permalink
feat: adding validation feedback to files from WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
ailtonloures committed Dec 14, 2024
1 parent d20d248 commit 504a185
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/core/wsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function wslBookmarkDataAdapter(path) {
};
}

function isFilePathFromWsl(path) {
function isPathFromWsl(path) {
return String(path).startsWith('\\\\wsl');
}

export { wslBookmarkDataAdapter, isFilePathFromWsl };
export { wslBookmarkDataAdapter, isPathFromWsl };
1 change: 0 additions & 1 deletion src/electron/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export * from './dialog';
export * from './icon';
export * from './label';
export * from './vite';
export * from './platform';
23 changes: 13 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import * as Sentry from '@sentry/electron';
import { app, ipcMain } from 'electron';

import { isFile } from './core/file-system';
import { isWindows } from './core/platform';
import { makeAppToInitOnASingleInstance } from './core/setup';
import { openIntoVsCode } from './core/vscode';
import { isFilePathFromWsl, wslBookmarkDataAdapter } from './core/wsl';
import { isPathFromWsl, wslBookmarkDataAdapter } from './core/wsl';
import store from './data/store';
import {
createBookmark,
deleteBookmarkById,
getBookmarks,
} from './data/store/bookmark';
import { createMenu, createTray, createWindow } from './electron';
import { isWindows, openDialog } from './electron/utils';
import { openDialog } from './electron/utils';

Sentry.init({
dsn: 'https://713782327975276ae010040b1db6ab8a@o4507887084503040.ingest.us.sentry.io/4507887098724352',
Expand Down Expand Up @@ -151,16 +152,18 @@ function renderApp(context) {
function getBookmarkDataFromFilePath(context, filePath) {
const { tray } = context;

if (isWindows() && isFilePathFromWsl(filePath)) {
if (!isFile(filePath)) return wslBookmarkDataAdapter(filePath);
if (isWindows() && isPathFromWsl(filePath)) {
if (isFile(filePath)) {
tray.displayBalloon({
iconType: 'warning',
title: 'Unsupported WSL path',
content: 'You can only save folders from WSL',
});

tray.displayBalloon({
iconType: 'warning',
title: 'Unsupported WSL path',
content: 'You can only save folders from WSL',
});
return null;
}

return null;
return wslBookmarkDataAdapter(filePath);
}

return { filePath };
Expand Down

0 comments on commit 504a185

Please sign in to comment.