fix(updater): dont change path if chdir returns error
This commit is contained in:
parent
04b39eff03
commit
2183af2deb
2 changed files with 17 additions and 15 deletions
|
@ -230,7 +230,7 @@ export class Browser extends React.Component<Props, State, {}> {
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
updater()
|
updater()
|
||||||
.setItems(this.props.browser.dirPath)
|
.setItems(this.props.browser.dirPath)
|
||||||
.then(() => {
|
.then((ok:boolean) => {
|
||||||
this.update(updater().updateBrowser);
|
this.update(updater().updateBrowser);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -159,7 +159,7 @@ export class Updater {
|
||||||
dirParts: List<string>,
|
dirParts: List<string>,
|
||||||
items: List<MetadataResp>,
|
items: List<MetadataResp>,
|
||||||
selectedItems: Map<string, boolean>
|
selectedItems: Map<string, boolean>
|
||||||
): Promise<void> => {
|
): Promise<boolean> => {
|
||||||
const pathsToDel = items
|
const pathsToDel = items
|
||||||
.filter((item) => {
|
.filter((item) => {
|
||||||
return selectedItems.has(item.name);
|
return selectedItems.has(item.name);
|
||||||
|
@ -200,32 +200,34 @@ export class Updater {
|
||||||
return this.setItems(dirParts);
|
return this.setItems(dirParts);
|
||||||
};
|
};
|
||||||
|
|
||||||
setItems = async (dirParts: List<string>): Promise<void> => {
|
setItems = async (dirParts: List<string>): Promise<boolean> => {
|
||||||
const dirPath = dirParts.join("/");
|
const dirPath = dirParts.join("/");
|
||||||
const listResp = await this.filesClient.list(dirPath);
|
const listResp = await this.filesClient.list(dirPath);
|
||||||
|
|
||||||
|
if (listResp.status === 200) {
|
||||||
this.props.browser.dirPath = dirParts;
|
this.props.browser.dirPath = dirParts;
|
||||||
this.props.browser.items =
|
this.props.browser.items = List<MetadataResp>(listResp.data.metadatas);
|
||||||
listResp.status === 200
|
return true;
|
||||||
? List<MetadataResp>(listResp.data.metadatas)
|
}
|
||||||
: this.props.browser.items;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
setHomeItems = async (): Promise<void> => {
|
setHomeItems = async (): Promise<boolean> => {
|
||||||
const listResp = await this.filesClient.listHome();
|
const listResp = await this.filesClient.listHome();
|
||||||
|
|
||||||
|
if (listResp.status === 200) {
|
||||||
this.props.browser.dirPath = List<string>(listResp.data.cwd.split("/"));
|
this.props.browser.dirPath = List<string>(listResp.data.cwd.split("/"));
|
||||||
this.props.browser.items =
|
this.props.browser.items = List<MetadataResp>(listResp.data.metadatas);
|
||||||
listResp.status === 200
|
return true;
|
||||||
? List<MetadataResp>(listResp.data.metadatas)
|
}
|
||||||
: this.props.browser.items;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
moveHere = async (
|
moveHere = async (
|
||||||
srcDir: string,
|
srcDir: string,
|
||||||
dstDir: string,
|
dstDir: string,
|
||||||
selectedItems: Map<string, boolean>
|
selectedItems: Map<string, boolean>
|
||||||
): Promise<void> => {
|
): Promise<boolean> => {
|
||||||
const itemsToMove = List<string>(selectedItems.keys()).map(
|
const itemsToMove = List<string>(selectedItems.keys()).map(
|
||||||
(itemName: string): any => {
|
(itemName: string): any => {
|
||||||
const from = getItemPath(srcDir, itemName);
|
const from = getItemPath(srcDir, itemName);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue