Skip to content

Commit

Permalink
彻底修复 vijos bug vijos#522
Browse files Browse the repository at this point in the history
  • Loading branch information
Limorton committed Nov 22, 2020
1 parent c859d09 commit 4c6dd2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion vj4/handler/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import zipfile
from bson import objectid
from urllib import parse
from pymongo import errors

from vj4 import app
from vj4 import constant
Expand Down Expand Up @@ -591,7 +592,9 @@ async def post(self, *, title: str, content: str, hidden: bool=False, numeric_pi
try:
pid = await problem.add(self.domain_id, title, content, self.user['_id'],
hidden=hidden, pid=pid)
except Exception as e:
except errors.DuplicateKeyError:
raise
except:
if numeric_pid:
await domain.dec_pid_counter(self.domain_id)
raise
Expand Down
2 changes: 1 addition & 1 deletion vj4/model/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def dec_pid_counter():
await coll.update_one(filter={'_id': 'pid_counter'},
update={'$setOnInsert': {'value': 1000}}, upsert=True)
doc = await coll.find_one_and_update(filter={'_id': 'pid_counter'},
update={'$dec': {'value': 1}})
update={'$inc': {'value': -1}})
return doc['value']

async def acquire_lock(lock_name: str):
Expand Down

0 comments on commit 4c6dd2e

Please sign in to comment.