Skip to content

Commit 75adee3

Browse files
authored
Improve history + disk error handling + rename (#51)
- FIXED: numerous filesystem bugs - ADDED: feedback for most disk operations - ADDED: new error property for fileCache in case folder cannot be accessed - IMPROVED: intelligent rename
1 parent 41a202f commit 75adee3

26 files changed

+645
-333
lines changed

img/link.png

374 Bytes
Loading

package-lock.json

Lines changed: 76 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"license": "MIT",
4747
"devDependencies": {
4848
"@types/classnames": "^2.2.7",
49-
"@types/del": "^3.0.1",
5049
"@types/i18next": "^12.1.0",
5150
"@types/react-i18next": "^8.1.0",
5251
"@types/react-virtualized": "^9.18.12",
@@ -63,6 +62,7 @@
6362
"source-map-loader": "^0.2.4",
6463
"style-loader": "^0.23.0",
6564
"typescript": "^3.1.1",
65+
"url-loader": "^1.1.2",
6666
"webpack": "^4.30.0",
6767
"webpack-cli": "^3.1.2"
6868
},
@@ -74,7 +74,7 @@
7474
"@types/react-dom": "^16.0.8",
7575
"basic-ftp": "^3.2.2",
7676
"classnames": "^2.2.6",
77-
"del": "^3.0.0",
77+
"del": "github:warpdesign/del",
7878
"electron-window-state": "^5.0.3",
7979
"get-folder-size": "^2.0.0",
8080
"i18next": "^13.0.0",

src/components/App.tsx

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { remote } from 'electron';
2323
import classnames from 'classnames';
2424
import { isPackage, isWin } from '../utils/platform';
2525
import { TabDescriptor } from "./TabList";
26+
import { getLocalizedError } from "../locale/error";
2627

2728
require("@blueprintjs/core/lib/css/blueprint.css");
2829
require("@blueprintjs/icons/lib/css/blueprint-icons.css");
@@ -438,7 +439,7 @@ class App extends React.Component<WithNamespaces, IState> {
438439
onDebugCache = () => {
439440
let i = 0;
440441
for (let cache of this.appState.views[0].caches) {
441-
console.log('cache', cache.selected.length, cache.selected, cache.selectedId, cache.editingId);
442+
console.log('cache', cache.selected.length, cache.selected, cache.selectedId, cache.editingId, cache);
442443
}
443444
}
444445

@@ -539,9 +540,40 @@ class App extends React.Component<WithNamespaces, IState> {
539540

540541
private onPaste = (): void => {
541542
const fileCache: FileState = this.getActiveFileCache();
542-
543-
if (fileCache) {
544-
this.appState.prepareClipboardTransferTo(fileCache);
543+
const appState = this.appState;
544+
545+
if (fileCache && !fileCache.error && appState.clipboard.files.length) {
546+
this.appState.prepareClipboardTransferTo(fileCache)
547+
.then((noErrors: any) => {
548+
const { t } = this.injected;
549+
if (noErrors) {
550+
AppToaster.show({
551+
message: t('COMMON.COPY_FINISHED'),
552+
icon: "tick",
553+
intent: Intent.SUCCESS,
554+
timeout: 3000
555+
});
556+
} else {
557+
AppToaster.show({
558+
message: t('COMMON.COPY_WARNING'),
559+
icon: "warning-sign",
560+
intent: Intent.WARNING,
561+
timeout: 5000
562+
});
563+
}
564+
})
565+
.catch((err: any) => {
566+
const { t } = this.injected;
567+
const localizedError = getLocalizedError(err);
568+
const message = err.code ? t('ERRORS.COPY_ERROR', { message: localizedError.message }) : t('ERRORS.COPY_UNKNOWN_ERROR');
569+
570+
AppToaster.show({
571+
message: message,
572+
icon: "error",
573+
intent: Intent.DANGER,
574+
timeout: 5000
575+
});
576+
});
545577
}
546578
}
547579

@@ -651,7 +683,7 @@ class App extends React.Component<WithNamespaces, IState> {
651683
</Navbar>
652684
<div onClickCapture={this.handleClick} className="main">
653685
<SideView viewState={viewStateLeft} hide={!isExplorer} onPaste={this.onPaste} />
654-
<SideView viewState={viewStateRight} hide={!isExplorer} onPaste={this.onPaste} />
686+
{<SideView viewState={viewStateRight} hide={!isExplorer} onPaste={this.onPaste} />}
655687
<Downloads hide={isExplorer} />
656688
</div>
657689
<LogUI></LogUI>

src/components/Downloads.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class DownloadsClass extends React.Component<IProps, IState> {
158158
}
159159

160160
getIntent(transfer: Batch) {
161+
console.log(transfer.status, transfer);
161162
const status = transfer.status;
162163
let intent: Intent = Intent.NONE;
163164
if (!status.match(/queued|calculating/)) {
@@ -190,9 +191,8 @@ class DownloadsClass extends React.Component<IProps, IState> {
190191
const currentSize = formatBytes(transfer.progress);
191192
const percent = transfer.status === 'calculating' ? 0 : transfer.progress / transfer.size;
192193
const ended = transfer.hasEnded;
193-
const error = transfer.status === 'error';
194-
const rightLabel = ended ? (error ? t('DOWNLOADS.ERROR') : t('DOWNLOADS.FINISHED', { size: sizeFormatted })) : t('DOWNLOADS.PROGRESS', { current: currentSize, size: transferSize });
195-
// const classes = classnames({[Classes.INTENT_DANGER]: error });
194+
const errors = transfer.numErrors;
195+
const rightLabel = ended ? (errors ? t('DOWNLOADS.FINISHED_ERRORS') : t('DOWNLOADS.FINISHED')) : t('DOWNLOADS.PROGRESS', { current: currentSize, size: transferSize });
196196

197197
return (
198198
<span className={className}>
@@ -254,13 +254,13 @@ class DownloadsClass extends React.Component<IProps, IState> {
254254

255255
let i = 0;
256256
for (let file of transfer.files) {
257-
if (!file.file.isDir) {
257+
if (!file.file.isDir || file.status === 'error') {
258258
const id = transfer.id + '_' + i;
259259
const filetype = file.file.type;
260260

261261
node.childNodes.push({
262262
id: id,
263-
icon: this.getFileIcon(filetype),
263+
icon: file.file.isDir ? 'folder-close' : this.getFileIcon(filetype),
264264
label: file.subDirectory ? (file.subDirectory + '/' + file.file.fullname) : file.file.fullname,
265265
secondaryLabel: this.createFileRightLabel(file),
266266
nodeData: {

0 commit comments

Comments
 (0)