mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[object-persistor] import ProjectKey helper from history-v1 (#30600)
GitOrigin-RevId: c72aa4bf91569904a2072c74d6ed2f3c764d97bb
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import settings from '@overleaf/settings'
|
||||
import * as projectKey from './project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
|
||||
export default {
|
||||
getConvertedFolderKey,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Keep in sync with services/history-v1/storage/lib/project_key.js
|
||||
import path from '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.
|
||||
//
|
||||
export function format(projectId) {
|
||||
const prefix = naiveReverse(pad(projectId))
|
||||
return path.join(prefix.slice(0, 3), prefix.slice(3, 6), prefix.slice(6))
|
||||
}
|
||||
|
||||
export function pad(number) {
|
||||
return (number || 0).toString().padStart(9, '0')
|
||||
}
|
||||
|
||||
function naiveReverse(string) {
|
||||
return string.split('').reverse().join('')
|
||||
}
|
||||
Reference in New Issue
Block a user