Commit 817ef0b8 authored by Romain Casati's avatar Romain Casati
Browse files

API: put* are async.

parent 0ca64aea
......@@ -85,11 +85,11 @@ export class KernelBase {
public restart(): void { throw new NotImplementedError("restart"); };
public putFile(filename: string, content: ArrayBuffer): void {
public async putFile(filename: string, content: ArrayBuffer): Promise<void> {
throw new NotImplementedError("putFile");
};
public putModule(filename: string, content: ArrayBuffer): void {
public async putModule(filename: string, content: ArrayBuffer): Promise<void> {
throw new NotImplementedError("putModule");
};
......@@ -231,12 +231,12 @@ export class KernelBase {
* Put a ressource (file or module).
* Detection is based on extension.
*/
public putRessource(filename: string, content: ArrayBuffer) {
public async putRessource(filename: string, content: ArrayBuffer) {
const ext = filename.split('.').pop() ?? "";
if (this.moduleExts().includes(ext)) {
return this.putModule(filename, content);
return await this.putModule(filename, content);
} else {
return this.putFile(filename, content);
return await this.putFile(filename, content);
}
};
......
......@@ -74,11 +74,11 @@ export class KernelJavaScript extends KernelBase {
public complete(code: string): [string[], number] | [] { return []; };
public putFile(filename: string, content: ArrayBuffer) {
public async putFile(filename: string, content: ArrayBuffer) {
console.error(`Fichier ${filename} not added since putFile has no mean in the JS context.`);
};
public putModule(filename: string, content: ArrayBuffer) {
public async putModule(filename: string, content: ArrayBuffer) {
content = new Uint8Array(content);
const ext = filename.split('.').pop();
switch (ext) {
......
......@@ -182,7 +182,7 @@ end`;
/**
* Put a file on the local (emulated) filesystem.
*/
public putFile(filename: string, content: ArrayBuffer) {
public async putFile(filename: string, content: ArrayBuffer) {
if (this.__kernel__ == null) return;
this.__kernel__.createfile(filename, content);
}
......@@ -191,7 +191,7 @@ end`;
* Put an importable module on the local (emulated) filesystem
* and load dependencies.
*/
public putModule(filename: string, content: ArrayBuffer) {
public async putModule(filename: string, content: ArrayBuffer) {
this.putFile(filename, content);
/* why is this needed?
* even if path is already added using the #directory directive,
......
......@@ -124,7 +124,7 @@ export class KernelPython3Old extends KernelBase {
/**
* Put a file on the local (emulated) filesystem.
*/
public putFile(filename: string, content: ArrayBuffer) {
public async putFile(filename: string, content: ArrayBuffer) {
this.__kernel__.put_file(filename, content);
}
......@@ -132,7 +132,7 @@ export class KernelPython3Old extends KernelBase {
* Put an importable module on the local (emulated) filesystem
* and load dependencies.
*/
public putModule(filename: string, content: ArrayBuffer) {
public async putModule(filename: string, content: ArrayBuffer) {
return this.__kernel__.put_module(filename, content);
}
......
......@@ -135,7 +135,7 @@ export class KernelPython3 extends KernelBase {
/**
* Put a file on the local (emulated) filesystem.
*/
public putFile(filename: string, content: ArrayBuffer) {
public async putFile(filename: string, content: ArrayBuffer) {
this.__kernel__.put_file(filename, content);
}
......
......@@ -152,11 +152,11 @@ export class KernelSQL extends KernelBase {
public complete(code: string): [string[], number] | [] { return []; };
public putFile(filename: string, content: ArrayBuffer) {
public async putFile(filename: string, content: ArrayBuffer) {
// just ignoring this since we don't have a filesystem.
};
public putModule(filename: string, content: ArrayBuffer) {
public async putModule(filename: string, content: ArrayBuffer) {
content = new Uint8Array(content);
const ext = filename.split('.').pop();
switch (ext) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment