[object-persistor] import ProjectKey helper from history-v1 (#30600)
GitOrigin-RevId: c72aa4bf91569904a2072c74d6ed2f3c764d97bb
This commit is contained in:
-1
@@ -1,4 +1,3 @@
|
||||
// Keep in sync with services/filestore/app/js/project_key.js
|
||||
const path = require('node:path')
|
||||
|
||||
//
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('chai')
|
||||
|
||||
const { format, pad } = require('../../../../storage/lib/project_key')
|
||||
const { format, pad } = require('../../src/ProjectKey.js')
|
||||
|
||||
describe('projectKey', function () {
|
||||
it('reverses padded keys', function () {
|
||||
@@ -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('')
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// @ts-check
|
||||
import path from 'node:path'
|
||||
import projectKey from './project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import {
|
||||
chunksBucket,
|
||||
backupPersistor,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// @ts-check
|
||||
import { callbackify } from 'util'
|
||||
import { callbackify } from 'node:util'
|
||||
import { ObjectId } from 'mongodb'
|
||||
import config from 'config'
|
||||
import OError from '@overleaf/o-error'
|
||||
import { db } from './mongodb.js'
|
||||
import projectKey from './project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import chunkStore from '../lib/chunk_store/index.js'
|
||||
import {
|
||||
backupPersistor,
|
||||
|
||||
@@ -12,7 +12,7 @@ import blobHash from './blob_hash.js'
|
||||
import { NotFoundError } from '@overleaf/object-persistor/src/Errors.js'
|
||||
import logger from '@overleaf/logger'
|
||||
import path from 'node:path'
|
||||
import projectKey from './project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import streams from './streams.js'
|
||||
import objectPersistor from '@overleaf/object-persistor'
|
||||
import { getEndDateForRPO } from '../../backupVerifier/utils.mjs'
|
||||
|
||||
@@ -16,7 +16,7 @@ const assert = require('../assert')
|
||||
const blobHash = require('../blob_hash')
|
||||
const mongodb = require('../mongodb')
|
||||
const persistor = require('../persistor')
|
||||
const projectKey = require('../project_key')
|
||||
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
|
||||
const streams = require('../streams')
|
||||
const postgresBackend = require('./postgres')
|
||||
const mongoBackend = require('./mongo')
|
||||
|
||||
@@ -15,7 +15,7 @@ const logger = require('@overleaf/logger')
|
||||
|
||||
const assert = require('./assert')
|
||||
const persistor = require('./persistor')
|
||||
const projectKey = require('./project_key')
|
||||
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
|
||||
const streams = require('./streams')
|
||||
|
||||
const Chunk = core.Chunk
|
||||
|
||||
@@ -12,7 +12,7 @@ const assert = require('./assert')
|
||||
const { BlobStore } = require('./blob_store')
|
||||
const persistor = require('./persistor')
|
||||
const ProjectArchive = require('./project_archive')
|
||||
const projectKey = require('./project_key')
|
||||
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
|
||||
const temp = require('./temp')
|
||||
|
||||
const BUCKET = config.get('zipStore.bucket')
|
||||
|
||||
@@ -40,7 +40,7 @@ import { backupGenerator } from '../lib/backupGenerator.mjs'
|
||||
import { promises as fs, createWriteStream } from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import projectKey from '../lib/project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import Crypto from 'node:crypto'
|
||||
import Stream from 'node:stream'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
@@ -29,7 +29,7 @@ const { Storage } = require('@google-cloud/storage')
|
||||
const isValidUtf8 = require('utf-8-validate')
|
||||
|
||||
const core = require('overleaf-editor-core')
|
||||
const projectKey = require('../lib/project_key')
|
||||
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
|
||||
const streams = require('../lib/streams')
|
||||
const ProjectArchive = require('../lib/project_archive')
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import { pipeline } from 'node:stream/promises'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { createHash } from 'node:crypto'
|
||||
import projectKey from '../lib/project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import { createGunzip } from 'node:zlib'
|
||||
import { text } from 'node:stream/consumers'
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const fs = require('node:fs')
|
||||
const readline = require('node:readline')
|
||||
const { History } = require('overleaf-editor-core')
|
||||
const { knex, historyStore, persistor } = require('..')
|
||||
const projectKey = require('../lib/project_key')
|
||||
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
|
||||
|
||||
const MAX_POSTGRES_INTEGER = 2147483647
|
||||
const DEFAULT_BATCH_SIZE = 1000
|
||||
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
} from '../../../../storage/lib/backupPersistor.mjs'
|
||||
import { makeProjectKey } from '../../../../storage/lib/blob_store/index.js'
|
||||
import config from 'config'
|
||||
import Stream from 'stream'
|
||||
import projectKey from '../../../../storage/lib/project_key.js'
|
||||
import Stream from 'node:stream'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import { ListObjectsV2Command } from '@aws-sdk/client-s3'
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
} from 'overleaf-editor-core'
|
||||
import Crypto from 'node:crypto'
|
||||
import path from 'node:path'
|
||||
import projectKey from '../../../../storage/lib/project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import { historyStore } from '../../../../storage/lib/history_store.js'
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
makeProjectKey,
|
||||
} from '../../../../storage/lib/blob_store/index.js'
|
||||
import { NotFoundError } from '@overleaf/object-persistor/src/Errors.js'
|
||||
import projectKey from '../../../../storage/lib/project_key.js'
|
||||
import projectKey from '@overleaf/object-persistor/src/ProjectKey.js'
|
||||
import { getBackupStatus } from '../../../../storage/lib/backup_store/index.js'
|
||||
import { text, buffer } from 'node:stream/consumers'
|
||||
import { createGunzip } from 'node:zlib'
|
||||
|
||||
Reference in New Issue
Block a user