Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
e4025563
Kaydet (Commit)
e4025563
authored
Şub 22, 2017
tarafından
chillaranand
Kaydeden (comit)
Tim Graham
Şub 24, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27836 -- Allowed FileSystemStorage.delete() to remove directories.
üst
339d526d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
storage.py
django/core/files/storage.py
+7
-4
tests.py
tests/file_storage/tests.py
+5
-0
No files found.
django/core/files/storage.py
Dosyayı görüntüle @
e4025563
...
...
@@ -293,12 +293,15 @@ class FileSystemStorage(Storage):
def
delete
(
self
,
name
):
assert
name
,
"The name argument is not allowed to be empty."
name
=
self
.
path
(
name
)
# If the file exists, delete it from the filesystem.
# If the file
or directory
exists, delete it from the filesystem.
try
:
os
.
remove
(
name
)
if
os
.
path
.
isdir
(
name
):
os
.
rmdir
(
name
)
else
:
os
.
remove
(
name
)
except
FileNotFoundError
:
# If
os.remove() fails with FileNotFoundError, the file may have
#
been removed
concurrently.
# If
removal fails, the file or directory may have been removed
# concurrently.
pass
def
exists
(
self
,
name
):
...
...
tests/file_storage/tests.py
Dosyayı görüntüle @
e4025563
...
...
@@ -495,6 +495,11 @@ class FileStorageTests(SimpleTestCase):
with
self
.
assertRaises
(
AssertionError
):
self
.
storage
.
delete
(
''
)
def
test_delete_deletes_directories
(
self
):
tmp_dir
=
tempfile
.
TemporaryDirectory
(
dir
=
self
.
storage
.
location
)
self
.
storage
.
delete
(
tmp_dir
.
name
)
self
.
assertFalse
(
os
.
path
.
exists
(
tmp_dir
.
name
))
@override_settings
(
MEDIA_ROOT
=
'media_root'
,
MEDIA_URL
=
'media_url/'
,
...
...
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