Skip to content

Commit

Permalink
fix some bugs with metafile cache
Browse files Browse the repository at this point in the history
- must return integral timestamps for consistency
- properly handle symlink mode
  • Loading branch information
williamstein committed Nov 16, 2023
1 parent 8549dc8 commit 15cc434
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions websocketfs/lib/metadata-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ export class MetadataFile {
return { errno: -2 };
}
const data = v[1].split(" ");
const mtime = new Date(parseFloat(data[0]) * 1000);
// note that we intentionally use parseInt and throw away info
// that might be in the file. This is for consistency with
// the non-cached version of things.
const mtime = new Date(parseInt(data[0]) * 1000);
const attr = {
mtime,
atime: new Date(parseFloat(data[1]) * 1000),
atime: new Date(parseInt(data[1]) * 1000),
ctime: mtime,
blocks: parseInt(data[2]),
size: parseInt(data[3]),
Expand Down
5 changes: 3 additions & 2 deletions websocketfs/lib/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ interface Options {
// [filename-relative-to-mount-point-no-leading-/.]\0[mtime in seconds] [atime in seconds] [number of 512-byte blocks] [size] [symbolic mode string]\0\0
// This file is *not* assumed to be sorted (it's a 1-line file, so hard to sort in unix anyways).
// Here all of mtime, atime, blocks, size are decimal numbers, which may have a fractional part,
// and mode is a string like in ls. E.g., this find command does it (ignoring hidden files)::
// and mode is a string like in ls. E.g., this find command does it (ignoring hidden files).
// Y2K alert -- note the %.10T truncates times to integers, and will I guess fail a few hundred years from now.
//
// mkdir -p /tmp/meta; find * -printf "%p\0%T@ %A@ %b %s %M\0\0" | lz4 > .meta.lz4 && mv .meta.lz4 /tmp/meta/meta.lz4
// mkdir -p /tmp/meta; find * -printf "%p\0%.10T@ %.10A@ %b %s %M\0\0" | lz4 > .meta.lz4 && mv .meta.lz4 /tmp/meta/meta.lz4
//
// PATCHES: (This does not exist yet!) If metadataFile ends in .lz4 it is assumed to be lz4 compressed and gets automatically decompressed.
// If there are files metadataFile.patch.[n] (with n an integer), then they are diff-match-patch patches
Expand Down
2 changes: 2 additions & 0 deletions websocketfs/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function symbolicToMode(symbolic): number {
let mode;
if (symbolic.charAt(0) === "d") {
mode = "40";
} else if (symbolic.charAt(0) === "l") {
mode = "120";
} else {
mode = "100";
}
Expand Down
2 changes: 1 addition & 1 deletion websocketfs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "websocketfs",
"version": "0.13.0",
"version": "0.13.1",
"description": "Like sshfs, but over a WebSocket",
"main": "./dist/lib/index.js",
"scripts": {
Expand Down

0 comments on commit 15cc434

Please sign in to comment.