Skip to content

Commit 4e84769

Browse files
committed
fix: avoid inconsitency between lastModified and postedAt
1 parent be3818c commit 4e84769

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/handlers/handleWrite.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { getBoundary, parseFormdata } from "../parseFormdata.js"
33
import { decode, genRandStr, getDispFilename, params, parseExpiration, parsePath, WorkerError } from "../common.js"
44

55
async function createPaste(env, content, isPrivate, expire, short, createDate, passwd, filename) {
6-
createDate = createDate || new Date().toISOString()
6+
const now = new Date().toISOString()
7+
createDate = createDate || now
78
passwd = passwd || genRandStr(params.ADMIN_PATH_LEN)
89
const short_len = isPrivate ? params.PRIVATE_RAND_LEN : params.RAND_LEN
910

11+
// repeat until finding an unused name
1012
if (short === undefined) {
1113
while (true) {
1214
short = genRandStr(short_len)
@@ -20,7 +22,7 @@ async function createPaste(env, content, isPrivate, expire, short, createDate, p
2022
postedAt: createDate,
2123
passwd: passwd,
2224
filename: filename,
23-
lastModified: new Date().toISOString(),
25+
lastModified: now,
2426
},
2527
})
2628
let accessUrl = env.BASE_URL + "/" + short

0 commit comments

Comments
 (0)