summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordubiousjim <dubiousjim@gmail.com>2020-04-03 13:45:44 -0400
committerGitHub <noreply@github.com>2020-04-03 13:45:44 -0400
commitc5c3abc517a1729c2fcc0977bb1e792e06b7eb3c (patch)
treef83eb27a7febfa0bfe20c09de488fb0f4b7688c8
parentc0cb198114ccc2dc4fa2764d307ad985c456882a (diff)
adjust docs for Deno.seek (#4610)
-rw-r--r--cli/js/lib.deno.ns.d.ts5
-rw-r--r--cli/ops/fs.rs4
2 files changed, 6 insertions, 3 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index b76fac1a5..3242ee280 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -703,7 +703,8 @@ declare namespace Deno {
export function write(rid: number, data: Uint8Array): Promise<number>;
/** Synchronously seek a resource ID (`rid`) to the given `offset` under mode
- * given by `whence`. The current position within the resource is returned.
+ * given by `whence`. The new position within the resource (bytes from the
+ * start) is returned.
*
* const file = Deno.openSync('hello.txt', {read: true, write: true, truncate: true, create: true});
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello world"));
@@ -731,7 +732,7 @@ declare namespace Deno {
): number;
/** Seek a resource ID (`rid`) to the given `offset` under mode given by `whence`.
- * The call resolves to the current position within the resource.
+ * The call resolves to the new position within the resource (bytes from the start).
*
* const file = await Deno.open('hello.txt', {read: true, write: true, truncate: true, create: true});
* await Deno.write(file.rid, new TextEncoder().encode("Hello world"));
diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs
index c076b2b24..43f3db614 100644
--- a/cli/ops/fs.rs
+++ b/cli/ops/fs.rs
@@ -226,12 +226,14 @@ fn op_seek(
};
let mut file = futures::executor::block_on(tokio_file.try_clone())?;
+ let is_sync = args.promise_id.is_none();
let fut = async move {
+ debug!("op_seek {} {} {}", rid, offset, whence);
let pos = file.seek(seek_from).await?;
Ok(json!(pos))
};
- if args.promise_id.is_none() {
+ if is_sync {
let buf = futures::executor::block_on(fut)?;
Ok(JsonOp::Sync(buf))
} else {