Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
4785dfac
Commit
4785dfac
authored
Apr 25, 2019
by
Philip Meier
Committed by
Soumith Chintala
Apr 25, 2019
Browse files
Fix logic error in check_integrity (#871)
* fixed check integrity * stylistic changes * flake8
parent
90091b5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
torchvision/datasets/utils.py
torchvision/datasets/utils.py
+16
-11
No files found.
torchvision/datasets/utils.py
View file @
4785dfac
...
@@ -17,20 +17,25 @@ def gen_bar_updater():
...
@@ -17,20 +17,25 @@ def gen_bar_updater():
return
bar_update
return
bar_update
def
calculate_md5
(
fpath
,
chunk_size
=
1024
*
1024
):
md5
=
hashlib
.
md5
()
with
open
(
fpath
,
'rb'
)
as
f
:
for
chunk
in
iter
(
lambda
:
f
.
read
(
chunk_size
),
b
''
):
md5
.
update
(
chunk
)
return
md5
.
hexdigest
()
def
check_md5
(
fpath
,
md5
,
**
kwargs
):
return
md5
==
calculate_md5
(
fpath
,
**
kwargs
)
def
check_integrity
(
fpath
,
md5
=
None
):
def
check_integrity
(
fpath
,
md5
=
None
):
if
md5
is
None
:
return
True
if
not
os
.
path
.
isfile
(
fpath
):
if
not
os
.
path
.
isfile
(
fpath
):
return
False
return
False
md5o
=
hashlib
.
md5
()
if
md5
is
None
:
with
open
(
fpath
,
'rb'
)
as
f
:
# read in 1MB chunks
for
chunk
in
iter
(
lambda
:
f
.
read
(
1024
*
1024
),
b
''
):
md5o
.
update
(
chunk
)
md5c
=
md5o
.
hexdigest
()
if
md5c
!=
md5
:
return
False
return
True
return
True
else
:
return
check_md5
(
fpath
,
md5
)
def
makedir_exist_ok
(
dirpath
):
def
makedir_exist_ok
(
dirpath
):
...
...
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