From 43df53adaf43311078e62fd7eb20b218a021cc59 Mon Sep 17 00:00:00 2001 From: myleosu <33693783+myleosu@users.noreply.github.com> Date: Sat, 16 Nov 2019 20:59:21 +0800 Subject: [PATCH 1/3] Update admin.py FPSProblemImport bug --- problem/views/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/problem/views/admin.py b/problem/views/admin.py index ee04dc1..5b36859 100644 --- a/problem/views/admin.py +++ b/problem/views/admin.py @@ -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") From 02a32f1c028c3ac6360348b61209734c24b8e6d2 Mon Sep 17 00:00:00 2001 From: myleosu <33693783+myleosu@users.noreply.github.com> Date: Sat, 16 Nov 2019 21:56:03 +0800 Subject: [PATCH 2/3] Update admin.py --- problem/views/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problem/views/admin.py b/problem/views/admin.py index 5b36859..1549f53 100644 --- a/problem/views/admin.py +++ b/problem/views/admin.py @@ -676,8 +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成功 + tf.file.flush() + os.fsync(tf.file) problems = FPSParser(tf.name).parse() else: return self.error("Parse upload file error") From f2eb58062e0d72d827fb3683bdd3c24f560b460a Mon Sep 17 00:00:00 2001 From: myleosu <33693783+myleosu@users.noreply.github.com> Date: Sat, 16 Nov 2019 22:09:00 +0800 Subject: [PATCH 3/3] Update admin.py --- problem/views/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/problem/views/admin.py b/problem/views/admin.py index 1549f53..af66dc3 100644 --- a/problem/views/admin.py +++ b/problem/views/admin.py @@ -676,8 +676,10 @@ class FPSProblemImport(CSRFExemptAPIView): with tempfile.NamedTemporaryFile("wb") as tf: for chunk in file.chunks(4096): tf.file.write(chunk) + tf.file.flush() os.fsync(tf.file) + problems = FPSParser(tf.name).parse() else: return self.error("Parse upload file error")