Skip to content

Commit

Permalink
Fixed allocated size for sparse files if read from cache (GitHub issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Dec 12, 2021
1 parent b74cf2b commit 39dbcd8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/FileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ FileInfo::FileInfo( DirTree * tree,
, _next( 0 )
, _tree( tree )
{
/**
* Default constructor: All fields are initialized empty.
**/

_isLocalFile = true;
_isSparseFile = false;
_isIgnored = false;
Expand Down Expand Up @@ -74,6 +78,11 @@ FileInfo::FileInfo( const QString & filenameWithoutPath,
, _next( 0 )
, _tree( tree )
{
/**
* Constructor from a stat buffer (i.e. based on an lstat() call).
* This is the standard case.
**/

CHECK_PTR( statInfo );

_isLocalFile = true;
Expand Down Expand Up @@ -158,6 +167,11 @@ FileInfo::FileInfo( DirTree * tree,
, _next( 0 )
, _tree( tree )
{
/**
* Constructor from the bare necessary fields
* for use from a cache file reader
**/

_name = filenameWithoutPath;
_isLocalFile = true;
_isIgnored = false;
Expand Down Expand Up @@ -190,10 +204,14 @@ FileInfo::FileInfo( DirTree * tree,

_allocatedSize = _size;
}
else
else // blocks >= 0
{
// The "blocks" field is optional in the cache file for use for sparse
// files only.

_isSparseFile = true;
_blocks = blocks;
_allocatedSize = blocks * STD_BLOCK_SIZE;
}

// logDebug() << "Created FileInfo " << this << endl;
Expand Down

0 comments on commit 39dbcd8

Please sign in to comment.