-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect file type #1935
Detect file type #1935
Conversation
d5a9cca
to
9899a74
Compare
LocationWe have a nice suitable place for it
It will be something like:
Create it as Artifacts for testsAlso, take into account, we have this place General ideaI think reading some parts of target-file and searching "specific binary or not binary" symbols is a good idea and the right direction. Just a question, would it be simple just try some chunks of file with std::str::from_utf8. Because if it isn't UTF8: you will get error or result string Good habitAs soon as it's draft, no problems of course to skip |
|
|
ac37937
to
ce778fb
Compare
54a6b2c
to
acf3bfe
Compare
e8e32d3
to
681dc72
Compare
86eb51b
to
6bbdf21
Compare
Is this good to 🚢 ? Asking as I was bit skeptical about changes... |
6bbdf21
to
59df6db
Compare
da05549
to
ad60f99
Compare
986cc9a
to
5dc942a
Compare
application/client/src/app/ui/elements/navigator/providers/provider.files.ts
Outdated
Show resolved
Hide resolved
application/client/src/app/ui/elements/navigator/providers/provider.files.ts
Outdated
Show resolved
Hide resolved
@@ -34,7 +34,7 @@ export class Action extends CLIAction { | |||
return this.error; | |||
} | |||
|
|||
public execute(cli: Service): Promise<void> { | |||
public async execute(cli: Service): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember (please check it), but if fucntion
is async, we can return just Error
or throw new Error()
, instead Promise.reject(Error)
... but please check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a good example to better understand promises and async
stuff.
async function a() {
return new Error('Test');
}
async function b() {
return Promise.reject(new Error('Test'));
}
async function c() {
throw new Error('Test');
}
async function d() {
return new Promise(() => {
throw new Error('Test');
})
}
a().then((_) => {
console.error(`[A]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[A] - ok');
});
b().then((_) => {
console.error(`[B]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[B] - ok');
});
c().then((_) => {
console.error(`[C]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[C] - ok');
});
d().then((_) => {
console.error(`[D]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[D] - ok');
});
console:
[A]: CATCH: isn't handled
[C] - ok
[B] - ok
[D] - ok
Well returning new Error
will not reject promise, but return result with resolve
df97940
to
a760264
Compare
Rustcore should have functionality to detect the file type. If file type is binary or text, and if text what is the encoding of file. Resolves: esrlabs#1841
Added function in rs bindings to that it will be available in the node bindings on frontend.
Added code in TS to use the file detection functionality from rust core.
a760264
to
78858ba
Compare
application/apps/rustcore/ts-bindings/src/native/native.jobs.ts
Outdated
Show resolved
Hide resolved
application/client/src/app/ui/elements/navigator/providers/provider.files.ts
Outdated
Show resolved
Hide resolved
try { | ||
const stat = fs.statSync(filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure statements try/catch
are still actual after switching to async
code
@@ -34,7 +34,7 @@ export class Action extends CLIAction { | |||
return this.error; | |||
} | |||
|
|||
public execute(cli: Service): Promise<void> { | |||
public async execute(cli: Service): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a good example to better understand promises and async
stuff.
async function a() {
return new Error('Test');
}
async function b() {
return Promise.reject(new Error('Test'));
}
async function c() {
throw new Error('Test');
}
async function d() {
return new Promise(() => {
throw new Error('Test');
})
}
a().then((_) => {
console.error(`[A]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[A] - ok');
});
b().then((_) => {
console.error(`[B]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[B] - ok');
});
c().then((_) => {
console.error(`[C]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[C] - ok');
});
d().then((_) => {
console.error(`[D]: CATCH: isn't handled`);
}).catch((_) => {
console.log('[D] - ok');
});
console:
[A]: CATCH: isn't handled
[C] - ok
[B] - ok
[D] - ok
Well returning new Error
will not reject promise, but return result with resolve
@@ -34,25 +34,23 @@ export class Action extends CLIAction { | |||
return this.error; | |||
} | |||
|
|||
public execute(cli: Service): Promise<void> { | |||
public async execute(cli: Service): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also make sure, all places of this function's usage are checked and corrected also. It's quite radical change (sync -> async) and we should make sure - all calls of changed functions are corrected too.
9fba51c
to
2d62218
Compare
2d62218
to
b26d568
Compare
We converted execute method to asynchronous from synchronous and this commit wraps the usage of that async method inside try block to avoid errors
Rustcore should have functionality to detect the file type. If file type is binary or text, and if text what is the encoding of file.
Resolves: #1841