@@ -368,7 +368,7 @@ private function rsGet($path)
368
368
$ url = $ this ->getRsHost () . $ path ;
369
369
return $ this ->get ($ url );
370
370
}
371
-
371
+
372
372
private function get ($ url )
373
373
{
374
374
$ headers = $ this ->auth ->authorization ($ url );
@@ -390,21 +390,21 @@ private function post($url, $body)
390
390
return array ($ r , null );
391
391
}
392
392
393
- public static function buildBatchCopy ($ source_bucket , $ key_pairs , $ target_bucket )
393
+ public static function buildBatchCopy ($ source_bucket , $ key_pairs , $ target_bucket, $ force )
394
394
{
395
- return self ::twoKeyBatch ('/copy ' , $ source_bucket , $ key_pairs , $ target_bucket );
395
+ return self ::twoKeyBatch ('/copy ' , $ source_bucket , $ key_pairs , $ target_bucket, $ force );
396
396
}
397
397
398
398
399
- public static function buildBatchRename ($ bucket , $ key_pairs )
399
+ public static function buildBatchRename ($ bucket , $ key_pairs, $ force )
400
400
{
401
- return self ::buildBatchMove ($ bucket , $ key_pairs , $ bucket );
401
+ return self ::buildBatchMove ($ bucket , $ key_pairs , $ bucket, $ force );
402
402
}
403
403
404
404
405
- public static function buildBatchMove ($ source_bucket , $ key_pairs , $ target_bucket )
405
+ public static function buildBatchMove ($ source_bucket , $ key_pairs , $ target_bucket, $ force )
406
406
{
407
- return self ::twoKeyBatch ('/move ' , $ source_bucket , $ key_pairs , $ target_bucket );
407
+ return self ::twoKeyBatch ('/move ' , $ source_bucket , $ key_pairs , $ target_bucket, $ force );
408
408
}
409
409
410
410
@@ -455,16 +455,20 @@ private static function oneKeyBatch($operation, $bucket, $keys)
455
455
return $ data ;
456
456
}
457
457
458
- private static function twoKeyBatch ($ operation , $ source_bucket , $ key_pairs , $ target_bucket )
458
+ private static function twoKeyBatch ($ operation , $ source_bucket , $ key_pairs , $ target_bucket, $ force )
459
459
{
460
460
if ($ target_bucket === null ) {
461
461
$ target_bucket = $ source_bucket ;
462
462
}
463
463
$ data = array ();
464
+ $ forceOp = "false " ;
465
+ if ($ force ) {
466
+ $ forceOp = "true " ;
467
+ }
464
468
foreach ($ key_pairs as $ from_key => $ to_key ) {
465
469
$ from = \Qiniu \entry ($ source_bucket , $ from_key );
466
470
$ to = \Qiniu \entry ($ target_bucket , $ to_key );
467
- array_push ($ data , $ operation . '/ ' . $ from . '/ ' . $ to );
471
+ array_push ($ data , $ operation . '/ ' . $ from . '/ ' . $ to . " /force/ " . $ forceOp );
468
472
}
469
473
return $ data ;
470
474
}
0 commit comments