Skip to content
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

chore: Avoid using rid-based filesystem functions #2763

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions _util/download_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@ export async function downloadFile(url: string, fileUrl: URL) {

await ensureFile(fromFileUrl(fileUrl));
const file = await Deno.open(fileUrl, { truncate: true, write: true });
for await (const chunk of response.body) {
Deno.writeSync(file.rid, chunk);
}
file.close();
await response.body.pipeTo(file.writable);
}
4 changes: 2 additions & 2 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class FileReader implements Reader {
if (!this.#file) {
this.#file = await Deno.open(this.filePath, { read: true });
}
const res = await Deno.read(this.#file.rid, p);
const res = await this.#file.read(p);
if (res === null) {
Deno.close(this.#file.rid);
this.#file.close();
this.#file = undefined;
}
return res;
Expand Down
2 changes: 1 addition & 1 deletion http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async function fetchExactPath(
});
} finally {
if (conn) {
Deno.close(conn.rid);
conn.close();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion io/buffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ Deno.test("readLinesWithEncodingISO-8859-15", async function () {
lines_.push(l);
}

Deno.close(file_.rid);
file_.close();

assertEquals(lines_.length, 12);
assertEquals(lines_, [
Expand Down
2 changes: 1 addition & 1 deletion log/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class RotatingFileHandler extends FileHandler {

rotateLogFiles() {
this._buf.flush();
Deno.close(this._file!.rid);
this._file!.close();

for (let i = this.#maxBackupCount - 1; i >= 0; i--) {
const source = this._filename + (i === 0 ? "" : "." + i);
Expand Down
2 changes: 1 addition & 1 deletion node/_tools/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function decompressTests(archivePath: string) {
);

const buffer = new Buffer(gunzip(await readAll(compressedFile)));
Deno.close(compressedFile.rid);
compressedFile.close();

const tar = new Untar(buffer);
const outFolder = dirname(fromFileUrl(new URL(archivePath, import.meta.url)));
Expand Down
8 changes: 4 additions & 4 deletions streams/conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export function readableStreamFromReader(
* // Example from file
* const file = await Deno.open("my_file.txt", {read: true});
* const myFileContent = await readAll(file);
* Deno.close(file.rid);
* file.close();
*
* // Example from buffer
* const myData = new Uint8Array(100);
Expand Down Expand Up @@ -378,7 +378,7 @@ export async function readAll(r: Deno.Reader): Promise<Uint8Array> {
* // Example from file
* const file = Deno.openSync("my_file.txt", {read: true});
* const myFileContent = readAllSync(file);
* Deno.close(file.rid);
* file.close();
*
* // Example from buffer
* const myData = new Uint8Array(100);
Expand Down Expand Up @@ -407,7 +407,7 @@ export function readAllSync(r: Deno.ReaderSync): Uint8Array {
* contentBytes = new TextEncoder().encode("Hello World");
* const file = await Deno.open('test.file', {write: true});
* await writeAll(file, contentBytes);
* Deno.close(file.rid);
* file.close();
*
* // Example writing to buffer
* contentBytes = new TextEncoder().encode("Hello World");
Expand Down Expand Up @@ -438,7 +438,7 @@ export async function writeAll(w: Deno.Writer, arr: Uint8Array) {
* contentBytes = new TextEncoder().encode("Hello World");
* const file = Deno.openSync('test.file', {write: true});
* writeAllSync(file, contentBytes);
* Deno.close(file.rid);
* file.close();
*
* // Example writing to buffer
* contentBytes = new TextEncoder().encode("Hello World");
Expand Down