Skip to content

Commit

Permalink
Resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeeptarlekar committed Feb 14, 2024
1 parent e0bf309 commit a760264
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 35 deletions.
7 changes: 3 additions & 4 deletions application/apps/indexer/session/src/unbound/commands/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::events::{ComputationError, ComputationError::OperationNotSupported};
use file_tools::is_binary;

pub fn is_file_binary(file_path: String) -> Result<CommandOutcome<bool>, ComputationError> {
match is_binary(file_path) {
Ok(is_binary) => Ok(Finished(is_binary)),
Err(err) => Err(OperationNotSupported(err.to_string())),
}
is_binary(file_path)
.map(Finished)
.map_err(|err| OperationNotSupported(err.to_string()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { bridge } from '@service/bridge';
import { EntityType, getFileName } from '@platform/types/files';
import { notifications, Notification } from '@ui/service/notifications';

import { scope } from '@platform/env/scope';
import * as Factory from '@platform/types/observe/factory';
import { IMenuItem } from '@ui/service/contextmenu';

Expand All @@ -15,7 +14,6 @@ const DEFAULT_LEN = 20000;
export class Provider extends Base<IFileDescription> {
protected count: number = 0;
protected roots: string[] = [];
protected logger = scope.getLogger('ProviderLogger');

protected async scan(roots: string[], folders: string[]): Promise<IFileDescription[]> {
if (this.isAborted()) {
Expand Down Expand Up @@ -143,7 +141,7 @@ export class Provider extends Base<IFileDescription> {
bridge.files().getByPath([item.filename])
.then((files) => {
if (files.length > 1) {
this.logger.info('More than one file detected')
this.ilc.log().info("More than one file detected");
return
}
const filetype = files[0].type;
Expand Down Expand Up @@ -174,7 +172,7 @@ export class Provider extends Base<IFileDescription> {
}
})
.catch((error) => {
this.logger.error(error);
this.ilc.log().error(error);
throw error;
});

Expand Down
4 changes: 1 addition & 3 deletions application/holder/src/service/bridge/file/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export const handler = Requests.InjectLogger<
})
)
})
.catch(error => {
reject(error);
});
.catch(reject);
})
.catch(reject);
});
Expand Down
18 changes: 7 additions & 11 deletions application/holder/src/service/bridge/file/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import { electron } from '@service/electron';
import { File } from 'platform/types/files';
import { FileType } from 'platform/types/observe/types/file';
import { getFileEntities } from '@env/fs';
import { scope } from "platform/env/scope";

import * as Requests from 'platform/ipc/request';

function any(ext?: string): Promise<File[]> {
const logger = scope.getLogger('SelectFile');
return new Promise((resolve, reject) => {
electron
.dialogs()
Expand All @@ -24,12 +22,7 @@ function any(ext?: string): Promise<File[]> {
resolve(entities);
}
})
// TODO: Add error log
.catch((error) => {
logger.error(`Error while opening a file; ${error}`);
throw error;
});

.catch(reject);
})
.catch(reject);
});
Expand All @@ -49,7 +42,8 @@ function dlt(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand All @@ -69,7 +63,8 @@ function pcapng(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand All @@ -89,7 +84,8 @@ function pcap(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand Down
12 changes: 8 additions & 4 deletions application/holder/src/service/bridge/folder/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function any(ext?: string): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand All @@ -43,7 +44,8 @@ function dlt(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand All @@ -60,7 +62,8 @@ function pcapng(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand All @@ -77,7 +80,8 @@ function pcap(): Promise<File[]> {
} else {
resolve(entities);
}
});
})
.catch(reject);
})
.catch(reject);
});
Expand Down
16 changes: 7 additions & 9 deletions application/holder/src/service/cli/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@ export class Action extends CLIAction {

public async execute(cli: Service): Promise<void> {
if (this.error.length > 0) {
return Promise.reject(
new Error(
`Handler cannot be executed, because errors: \n${this.error
.map((e) => e.message)
.join('\n')}`,
),
return new Error(
`Handler cannot be executed, because errors: \n${this.error
.map((e) => e.message)
.join('\n')}`,
);
}
if (!this.defined()) {
return Promise.resolve();
return
}
const files = await getFileEntities(this.files);
if (files instanceof Error) {
return Promise.reject(files);
return files;
}
if (files.length === 0) {
return Promise.resolve();
return;
}
const observe =
files.length === 1
Expand Down

0 comments on commit a760264

Please sign in to comment.