Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5dbdc595
Kaydet (Commit)
5dbdc595
authored
Agu 27, 2005
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1168594: set sizes of non-regular files to zero. Fixes #1167128.
Will backport to 2.4.
üst
9e34c047
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
14 deletions
+49
-14
tarfile.py
Lib/tarfile.py
+12
-14
test_tarfile.py
Lib/test/test_tarfile.py
+35
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/tarfile.py
Dosyayı görüntüle @
5dbdc595
...
...
@@ -1179,17 +1179,16 @@ class TarFile(object):
# Fill the TarInfo object with all
# information we can get.
tarinfo
.
name
=
arcname
tarinfo
.
mode
=
stmd
tarinfo
.
uid
=
statres
.
st_uid
tarinfo
.
gid
=
statres
.
st_gid
if
stat
.
S_ISDIR
(
stmd
):
# For a directory, the size must be 0
tarinfo
.
size
=
0
else
:
tarinfo
.
name
=
arcname
tarinfo
.
mode
=
stmd
tarinfo
.
uid
=
statres
.
st_uid
tarinfo
.
gid
=
statres
.
st_gid
if
stat
.
S_ISREG
(
stmd
):
tarinfo
.
size
=
statres
.
st_size
else
:
tarinfo
.
size
=
0L
tarinfo
.
mtime
=
statres
.
st_mtime
tarinfo
.
type
=
type
tarinfo
.
type
=
type
tarinfo
.
linkname
=
linkname
if
pwd
:
try
:
...
...
@@ -1280,16 +1279,15 @@ class TarFile(object):
self
.
addfile
(
tarinfo
,
f
)
f
.
close
()
if
tarinfo
.
type
in
(
LNKTYPE
,
SYMTYPE
,
FIFOTYPE
,
CHRTYPE
,
BLKTYPE
):
tarinfo
.
size
=
0L
self
.
addfile
(
tarinfo
)
if
tarinfo
.
isdir
():
elif
tarinfo
.
isdir
():
self
.
addfile
(
tarinfo
)
if
recursive
:
for
f
in
os
.
listdir
(
name
):
self
.
add
(
os
.
path
.
join
(
name
,
f
),
os
.
path
.
join
(
arcname
,
f
))
else
:
self
.
addfile
(
tarinfo
)
def
addfile
(
self
,
tarinfo
,
fileobj
=
None
):
"""Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
given, tarinfo.size bytes are read from it and added to the archive.
...
...
Lib/test/test_tarfile.py
Dosyayı görüntüle @
5dbdc595
...
...
@@ -230,6 +230,40 @@ class WriteTest(BaseTest):
else
:
self
.
dst
.
addfile
(
tarinfo
,
f
)
class
WriteSize0Test
(
BaseTest
):
mode
=
'w'
def
setUp
(
self
):
self
.
tmpdir
=
dirname
()
self
.
dstname
=
tmpname
()
self
.
dst
=
tarfile
.
open
(
self
.
dstname
,
"w"
)
def
tearDown
(
self
):
self
.
dst
.
close
()
def
test_file
(
self
):
path
=
os
.
path
.
join
(
self
.
tmpdir
,
"file"
)
file
(
path
,
"w"
)
tarinfo
=
self
.
dst
.
gettarinfo
(
path
)
self
.
assertEqual
(
tarinfo
.
size
,
0
)
file
(
path
,
"w"
)
.
write
(
"aaa"
)
tarinfo
=
self
.
dst
.
gettarinfo
(
path
)
self
.
assertEqual
(
tarinfo
.
size
,
3
)
def
test_directory
(
self
):
path
=
os
.
path
.
join
(
self
.
tmpdir
,
"directory"
)
os
.
mkdir
(
path
)
tarinfo
=
self
.
dst
.
gettarinfo
(
path
)
self
.
assertEqual
(
tarinfo
.
size
,
0
)
def
test_symlink
(
self
):
if
hasattr
(
os
,
"symlink"
):
path
=
os
.
path
.
join
(
self
.
tmpdir
,
"symlink"
)
os
.
symlink
(
"link_target"
,
path
)
tarinfo
=
self
.
dst
.
gettarinfo
(
path
)
self
.
assertEqual
(
tarinfo
.
size
,
0
)
class
WriteStreamTest
(
WriteTest
):
sep
=
'|'
...
...
@@ -399,6 +433,7 @@ def test_main():
ReadAsteriskTest
,
ReadStreamAsteriskTest
,
WriteTest
,
WriteSize0Test
,
WriteStreamTest
,
WriteGNULongTest
,
]
...
...
Misc/NEWS
Dosyayı görüntüle @
5dbdc595
...
...
@@ -204,6 +204,8 @@ Extension Modules
Library
-------
-
Bug
#
1167128
:
Fix
size
of
a
symlink
in
a
tarfile
to
be
0.
-
Patch
#
810023
:
Fix
off
-
by
-
one
bug
in
urllib
.
urlretrieve
reporthook
functionality
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment