Skip to content

Commit 3ada37a

Browse files
authored
Add files via upload
1 parent 008334e commit 3ada37a

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

pycatfile.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5934,7 +5934,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59345934
if(hasattr(os.path, "isjunction") and os.path.isjunction(fname)):
59355935
ftype = 13
59365936
elif(stat.S_ISREG(fpremode)):
5937-
if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_blocks * 512 < fstatinfo.st_size):
5937+
if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_size > 0 and fstatinfo.st_blocks * 512 < fstatinfo.st_size):
59385938
ftype = 12
59395939
else:
59405940
ftype = 0
@@ -5960,31 +5960,29 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59605960
ftype = 0
59615961
flinkname = ""
59625962
fcurfid = format(int(curfid), 'x').lower()
5963-
if not followlink and finode != 0:
5963+
if(not followlink and finode != 0):
59645964
unique_id = (fstatinfo.st_dev, finode)
5965-
if ftype != 1:
5966-
if unique_id in inodelist:
5965+
if(ftype != 1):
5966+
if(unique_id in inodetofile):
59675967
# Hard link detected
59685968
ftype = 1
59695969
flinkname = inodetofile[unique_id]
5970-
if altinode:
5971-
fcurinode = format(int(unique_id[1]), 'x').lower()
5972-
else:
5973-
fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59745970
else:
5975-
# New inode
5976-
inodelist.append(unique_id)
5971+
# First time seeing this inode
59775972
inodetofile[unique_id] = fname
5973+
if(unique_id not in inodetoforminode):
59785974
inodetoforminode[unique_id] = curinode
5979-
if altinode:
5980-
fcurinode = format(int(unique_id[1]), 'x').lower()
5981-
else:
5982-
fcurinode = format(int(curinode), 'x').lower()
5983-
curinode += 1
5975+
curinode = curinode + 1
5976+
if(altinode):
5977+
# altinode == True → use real inode number
5978+
fcurinode = format(int(unique_id[1]), 'x').lower()
5979+
else:
5980+
# altinode == False → use synthetic inode id
5981+
fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59845982
else:
59855983
# Handle cases where inodes are not supported or symlinks are followed
59865984
fcurinode = format(int(curinode), 'x').lower()
5987-
curinode += 1
5985+
curinode = curinode + 1
59885986
curfid = curfid + 1
59895987
if(ftype == 2):
59905988
flinkname = os.readlink(fname)

0 commit comments

Comments
 (0)