Skip to content

Commit bcfaa17

Browse files
authored
Add files via upload
1 parent c70095a commit bcfaa17

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

pyarchivefile.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5927,7 +5927,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59275927
if(hasattr(os.path, "isjunction") and os.path.isjunction(fname)):
59285928
ftype = 13
59295929
elif(stat.S_ISREG(fpremode)):
5930-
if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_blocks * 512 < fstatinfo.st_size):
5930+
if(hasattr(fstatinfo, "st_blocks") and fstatinfo.st_size > 0 and fstatinfo.st_blocks * 512 < fstatinfo.st_size):
59315931
ftype = 12
59325932
else:
59335933
ftype = 0
@@ -5953,31 +5953,29 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
59535953
ftype = 0
59545954
flinkname = ""
59555955
fcurfid = format(int(curfid), 'x').lower()
5956-
if not followlink and finode != 0:
5956+
if(not followlink and finode != 0):
59575957
unique_id = (fstatinfo.st_dev, finode)
5958-
if ftype != 1:
5959-
if unique_id in inodelist:
5958+
if(ftype != 1):
5959+
if(unique_id in inodetofile):
59605960
# Hard link detected
59615961
ftype = 1
59625962
flinkname = inodetofile[unique_id]
5963-
if altinode:
5964-
fcurinode = format(int(unique_id[1]), 'x').lower()
5965-
else:
5966-
fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59675963
else:
5968-
# New inode
5969-
inodelist.append(unique_id)
5964+
# First time seeing this inode
59705965
inodetofile[unique_id] = fname
5966+
if(unique_id not in inodetoforminode):
59715967
inodetoforminode[unique_id] = curinode
5972-
if altinode:
5973-
fcurinode = format(int(unique_id[1]), 'x').lower()
5974-
else:
5975-
fcurinode = format(int(curinode), 'x').lower()
5976-
curinode += 1
5968+
curinode = curinode + 1
5969+
if(altinode):
5970+
# altinode == True → use real inode number
5971+
fcurinode = format(int(unique_id[1]), 'x').lower()
5972+
else:
5973+
# altinode == False → use synthetic inode id
5974+
fcurinode = format(int(inodetoforminode[unique_id]), 'x').lower()
59775975
else:
59785976
# Handle cases where inodes are not supported or symlinks are followed
59795977
fcurinode = format(int(curinode), 'x').lower()
5980-
curinode += 1
5978+
curinode = curinode + 1
59815979
curfid = curfid + 1
59825980
if(ftype == 2):
59835981
flinkname = os.readlink(fname)
@@ -6049,7 +6047,6 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, extradata=[], json
60496047
fcencoding = "UTF-8"
60506048
curcompression = "none"
60516049
if not followlink and ftype in data_types:
6052-
print("not follow ",ftype)
60536050
with open(fname, "rb") as fpc:
60546051
shutil.copyfileobj(fpc, fcontents, length=__filebuff_size__)
60556052
typechecktest = CheckCompressionType(fcontents, filestart=0, closefp=False)

0 commit comments

Comments
 (0)