Refactor content headers and handle move operation
This commit is contained in:
parent
f81cee4647
commit
c104601ab1
@ -496,7 +496,7 @@ async function handle_move(request: Request, bucket: R2Bucket): Promise<Response
|
|||||||
switch (depth) {
|
switch (depth) {
|
||||||
case 'infinity': {
|
case 'infinity': {
|
||||||
let prefix = resource_path + '/';
|
let prefix = resource_path + '/';
|
||||||
const copy = async (object: R2Object) => {
|
const move = async (object: R2Object) => {
|
||||||
let target = destination + '/' + object.key.slice(prefix.length);
|
let target = destination + '/' + object.key.slice(prefix.length);
|
||||||
target = target.endsWith('/') ? target.slice(0, -1) : target;
|
target = target.endsWith('/') ? target.slice(0, -1) : target;
|
||||||
let src = await bucket.get(object.key);
|
let src = await bucket.get(object.key);
|
||||||
@ -508,9 +508,9 @@ async function handle_move(request: Request, bucket: R2Bucket): Promise<Response
|
|||||||
await bucket.delete(object.key);
|
await bucket.delete(object.key);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let promise_array = [copy(resource)];
|
let promise_array = [move(resource)];
|
||||||
for await (let object of listAll(bucket, prefix, true)) {
|
for await (let object of listAll(bucket, prefix, true)) {
|
||||||
promise_array.push(copy(object));
|
promise_array.push(move(object));
|
||||||
}
|
}
|
||||||
await Promise.all(promise_array);
|
await Promise.all(promise_array);
|
||||||
if (destination_exists) {
|
if (destination_exists) {
|
||||||
|
Loading…
Reference in New Issue
Block a user