mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 06:39:01 +02:00
29045b9085
* [history-v1] use String.padStart instead of lodash.padStart * [web] download binary files in clsi from filestore via new endpoints * [server-ce] tests: Cypress.env() is parsing boolean values * [server-ce] tests: run history migration as root GitOrigin-RevId: bdf6c0e542531ccc4b3f13d2ed68ca0d31e580e9
24 lines
664 B
JavaScript
24 lines
664 B
JavaScript
// Keep in sync with services/filestore/app/js/project_key.js
|
|
const path = require('node:path')
|
|
|
|
//
|
|
// The advice in http://docs.aws.amazon.com/AmazonS3/latest/dev/
|
|
// request-rate-perf-considerations.html is to avoid sequential key prefixes,
|
|
// so we reverse the project ID part of the key as they suggest.
|
|
//
|
|
function format(projectId) {
|
|
const prefix = naiveReverse(pad(projectId))
|
|
return path.join(prefix.slice(0, 3), prefix.slice(3, 6), prefix.slice(6))
|
|
}
|
|
|
|
function pad(number) {
|
|
return (number || 0).toString().padStart(9, '0')
|
|
}
|
|
|
|
function naiveReverse(string) {
|
|
return string.split('').reverse().join('')
|
|
}
|
|
|
|
exports.format = format
|
|
exports.pad = pad
|