@@ -5935,7 +5935,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59355935 if(hasattr(os.path, "isjunction") and os.path.isjunction(fname)):
59365936 ftype = 13
59375937 elif(stat.S_ISREG(fpremode)):
5938- if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_blocks * 512 < fstatinfo.st_size):
5938+ if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_size > 0 and fstatinfo. st_blocks * 512 < fstatinfo.st_size):
59395939 ftype = 12
59405940 else:
59415941 ftype = 0
@@ -5961,31 +5961,29 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59615961 ftype = 0
59625962 flinkname = ""
59635963 fcurfid = format(int(curfid), 'x').lower()
5964- if not followlink and finode != 0:
5964+ if( not followlink and finode != 0) :
59655965 unique_id = (fstatinfo.st_dev, finode)
5966- if ftype != 1:
5967- if unique_id in inodelist :
5966+ if( ftype != 1) :
5967+ if( unique_id in inodetofile) :
59685968 # Hard link detected
59695969 ftype = 1
59705970 flinkname = inodetofile[unique_id]
5971- if altinode:
5972- fcurinode = format(int(unique_id[1]), 'x').lower()
5973- else:
5974- fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59755971 else:
5976- # New inode
5977- inodelist.append(unique_id)
5972+ # First time seeing this inode
59785973 inodetofile[unique_id] = fname
5974+ if(unique_id not in inodetoforminode):
59795975 inodetoforminode[unique_id] = curinode
5980- if altinode:
5981- fcurinode = format(int(unique_id[1]), 'x').lower()
5982- else:
5983- fcurinode = format(int(curinode), 'x').lower()
5984- curinode += 1
5976+ curinode = curinode + 1
5977+ if(altinode):
5978+ # altinode == True → use real inode number
5979+ fcurinode = format(int(unique_id[1]), 'x').lower()
5980+ else:
5981+ # altinode == False → use synthetic inode id
5982+ fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59855983 else:
59865984 # Handle cases where inodes are not supported or symlinks are followed
59875985 fcurinode = format(int(curinode), 'x').lower()
5988- curinode += 1
5986+ curinode = curinode + 1
59895987 curfid = curfid + 1
59905988 if(ftype == 2):
59915989 flinkname = os.readlink(fname)
0 commit comments