tdweb: getFilePart (not tested)
GitOrigin-RevId: 7201a7d4da41bb8f42a934fb149e80e08f9e6309
This commit is contained in:
parent
75db56dcb3
commit
7a6a506e9e
@ -19,6 +19,8 @@ const sleep = ms => new Promise(res => setTimeout(res, ms));
|
|||||||
* 3. file <..as in td_api..> idb_key:string = File; <br>
|
* 3. file <..as in td_api..> idb_key:string = File; <br>
|
||||||
* 2. setJsLogVerbosityLevel new_verbosity_level:string = Ok;
|
* 2. setJsLogVerbosityLevel new_verbosity_level:string = Ok;
|
||||||
* 3. inputFileBlob blob:<javascript blob> = InputFile;<br>
|
* 3. inputFileBlob blob:<javascript blob> = InputFile;<br>
|
||||||
|
* 4. readFilePart path:string offset:int64 size:int64 = FilePart;<br>
|
||||||
|
* filePart data:blob = FilePart;<br>
|
||||||
* <br>
|
* <br>
|
||||||
*/
|
*/
|
||||||
class TdClient {
|
class TdClient {
|
||||||
|
@ -475,6 +475,26 @@ class TdClient {
|
|||||||
log.info('ignore on_start');
|
log.info('ignore on_start');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readFilePart(query) {
|
||||||
|
var res;
|
||||||
|
try {
|
||||||
|
//let file_size = this.FS.stat(query.path).size;
|
||||||
|
var stream = this.FS.open(query.path, 'r');
|
||||||
|
var buf = new Uint8Array(query.size);
|
||||||
|
this.FS.read(stream, buf, 0, query.size, query.offset);
|
||||||
|
this.FS.close(stream);
|
||||||
|
res = buf
|
||||||
|
} catch (e) {
|
||||||
|
this.callback({'@type':'error', '@extra': query['@extra'], code: 400, message: e});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.callback({
|
||||||
|
'@type': 'FilePart',
|
||||||
|
'@extra': query['@extra'],
|
||||||
|
'data': res
|
||||||
|
}, [res.buffer]);
|
||||||
|
}
|
||||||
|
|
||||||
send(query) {
|
send(query) {
|
||||||
if (this.isClosing) {
|
if (this.isClosing) {
|
||||||
return;
|
return;
|
||||||
@ -498,6 +518,10 @@ class TdClient {
|
|||||||
log.setVerbosity(query.new_verbosity_level);
|
log.setVerbosity(query.new_verbosity_level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.isPending) {
|
||||||
|
this.pendingQueries.push(query);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (query['@type'] === 'setLogVerbosityLevel' ||
|
if (query['@type'] === 'setLogVerbosityLevel' ||
|
||||||
query['@type'] === 'getLogVerbosityLevel' ||
|
query['@type'] === 'getLogVerbosityLevel' ||
|
||||||
query['@type'] === 'setLogTagVerbosityLevel' ||
|
query['@type'] === 'setLogTagVerbosityLevel' ||
|
||||||
@ -506,8 +530,8 @@ class TdClient {
|
|||||||
this.execute(query);
|
this.execute(query);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.isPending) {
|
if (query['@type'] === 'readFilePart') {
|
||||||
this.pendingQueries.push(query);
|
this.readFilePart(query);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
query = this.prepareQuery(query);
|
query = this.prepareQuery(query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user