Update admin.py

FPSProblemImport bug
This commit is contained in:
myleosu 2019-11-16 20:59:21 +08:00 committed by GitHub
parent 5503b02920
commit 43df53adaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -676,6 +676,8 @@ class FPSProblemImport(CSRFExemptAPIView):
with tempfile.NamedTemporaryFile("wb") as tf:
for chunk in file.chunks(4096):
tf.file.write(chunk)
tf.file.flush() #确保file写入tf成功
os.fsync(tf.file) #确保file写入tf成功
problems = FPSParser(tf.name).parse()
else:
return self.error("Parse upload file error")