Skip to content

Commit

Permalink
properly update file size in NodeSyncAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillp committed Nov 26, 2024
1 parent 58f8664 commit 188fa4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ JSString jsPath() {
}

private NodeFs.Stats stats() {
return stats == null ? (stats = Fs.fs().lstatSync(jsPath())) : stats;
return stats == null ? stats = actualStats(jsPath()) : stats;
}

// For actual size() value
private NodeFs.Stats actualStats() {
return stats = Fs.fs().lstatSync(jsPath());
static NodeFs.Stats actualStats(JSString jsPath) {
return Fs.fs().lstatSync(jsPath);
}

private int intSize() {
double jsSize = actualStats().size();
double jsSize = actualStats(jsPath()).size();
int result = (int) jsSize;
if (result != jsSize) {
JsHelper.consoleError(
Expand All @@ -76,7 +76,7 @@ private int intSize() {
public void syncAccess(Consumer<SyncAccess> consumer, Consumer<String> onError) {
try {
int handle = openSync(Fs.fs());
consumer.accept(new NodeSyncAccess(stats(), handle, jsPath()));
consumer.accept(new NodeSyncAccess(handle, jsPath()));
} catch (Exception e) {
onError.accept(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

public class NodeSyncAccess implements FileHandle.SyncAccess {

NodeFs.Stats stats;
int handle;
JSString path;

public NodeSyncAccess(NodeFs.Stats stats, int handle, JSString path) {
this.stats = stats;
public NodeSyncAccess(int handle, JSString path) {
this.handle = handle;
this.path = path;
}
Expand All @@ -25,7 +23,7 @@ public boolean close() {

@Override
public double getSize() {
return stats.size();
return NodeFileHandle.actualStats(path).size();
}

@Override
Expand Down

0 comments on commit 188fa4a

Please sign in to comment.