Skip to content

Commit

Permalink
Improve history + disk error handling + rename (#51)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
warpdesign authored May 27, 2019
1 parent 41a202f commit 75adee3
Show file tree
Hide file tree
Showing 26 changed files with 645 additions and 333 deletions.
Binary file added img/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 76 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"license": "MIT",
"devDependencies": {
"@types/classnames": "^2.2.7",
"@types/del": "^3.0.1",
"@types/i18next": "^12.1.0",
"@types/react-i18next": "^8.1.0",
"@types/react-virtualized": "^9.18.12",
Expand All @@ -63,6 +62,7 @@
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.0",
"typescript": "^3.1.1",
"url-loader": "^1.1.2",
"webpack": "^4.30.0",
"webpack-cli": "^3.1.2"
},
Expand All @@ -74,7 +74,7 @@
"@types/react-dom": "^16.0.8",
"basic-ftp": "^3.2.2",
"classnames": "^2.2.6",
"del": "^3.0.0",
"del": "github:warpdesign/del",
"electron-window-state": "^5.0.3",
"get-folder-size": "^2.0.0",
"i18next": "^13.0.0",
Expand Down
42 changes: 37 additions & 5 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { remote } from 'electron';
import classnames from 'classnames';
import { isPackage, isWin } from '../utils/platform';
import { TabDescriptor } from "./TabList";
import { getLocalizedError } from "../locale/error";

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

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

private onPaste = (): void => {
const fileCache: FileState = this.getActiveFileCache();

if (fileCache) {
this.appState.prepareClipboardTransferTo(fileCache);
const appState = this.appState;

if (fileCache && !fileCache.error && appState.clipboard.files.length) {
this.appState.prepareClipboardTransferTo(fileCache)
.then((noErrors: any) => {
const { t } = this.injected;
if (noErrors) {
AppToaster.show({
message: t('COMMON.COPY_FINISHED'),
icon: "tick",
intent: Intent.SUCCESS,
timeout: 3000
});
} else {
AppToaster.show({
message: t('COMMON.COPY_WARNING'),
icon: "warning-sign",
intent: Intent.WARNING,
timeout: 5000
});
}
})
.catch((err: any) => {
const { t } = this.injected;
const localizedError = getLocalizedError(err);
const message = err.code ? t('ERRORS.COPY_ERROR', { message: localizedError.message }) : t('ERRORS.COPY_UNKNOWN_ERROR');

AppToaster.show({
message: message,
icon: "error",
intent: Intent.DANGER,
timeout: 5000
});
});
}
}

Expand Down Expand Up @@ -651,7 +683,7 @@ class App extends React.Component<WithNamespaces, IState> {
</Navbar>
<div onClickCapture={this.handleClick} className="main">
<SideView viewState={viewStateLeft} hide={!isExplorer} onPaste={this.onPaste} />
<SideView viewState={viewStateRight} hide={!isExplorer} onPaste={this.onPaste} />
{<SideView viewState={viewStateRight} hide={!isExplorer} onPaste={this.onPaste} />}
<Downloads hide={isExplorer} />
</div>
<LogUI></LogUI>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class DownloadsClass extends React.Component<IProps, IState> {
}

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

return (
<span className={className}>
Expand Down Expand Up @@ -254,13 +254,13 @@ class DownloadsClass extends React.Component<IProps, IState> {

let i = 0;
for (let file of transfer.files) {
if (!file.file.isDir) {
if (!file.file.isDir || file.status === 'error') {
const id = transfer.id + '_' + i;
const filetype = file.file.type;

node.childNodes.push({
id: id,
icon: this.getFileIcon(filetype),
icon: file.file.isDir ? 'folder-close' : this.getFileIcon(filetype),
label: file.subDirectory ? (file.subDirectory + '/' + file.file.fullname) : file.file.fullname,
secondaryLabel: this.createFileRightLabel(file),
nodeData: {
Expand Down
Loading

0 comments on commit 75adee3

Please sign in to comment.