Skip to content

Commit

Permalink
fix (#268)
Browse files Browse the repository at this point in the history
fixing issue 264 (incorrect size check when re-opening a storage file for truncation)
  • Loading branch information
hg-ms authored Aug 13, 2024
1 parent 06175d2 commit f7ab7a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public final synchronized long copyFrom(
}
}

public final synchronized void truncate(final long newLength)
public synchronized void truncate(final long newLength)
{
this.ensureWritable().truncate(newLength);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ public long totalLength()
return this.fileTotalLength;
}

@Override
public synchronized void truncate(long newLength)
{
//Do not use this.internalOpenWriting() because this method does an size check
//if the file is re-opened.
//This size check is not appropriate if the file shall be opened with write access for truncation.
super.internalOpenWriting();
super.truncate(newLength);
}

final TypeInFile typeInFile(final StorageEntityType.Default type)
{
Expand Down Expand Up @@ -287,7 +296,7 @@ protected synchronized boolean internalOpenWriting()

return true;
}

@Override
public final double dataFillRatio()
{
Expand Down

0 comments on commit f7ab7a4

Please sign in to comment.