@@ -50,6 +50,15 @@ Client.prototype.move = function(bucketSrc, keySrc, bucketDest, keyDest, onret)
5050 rpc . postWithoutForm ( uri , digest , onret ) ;
5151}
5252
53+ Client . prototype . forceMove = function ( bucketSrc , keySrc , bucketDest , keyDest , force , onret ) {
54+
55+ var encodedEntryURISrc = getEncodedEntryUri ( bucketSrc , keySrc ) ;
56+ var encodedEntryURIDest = getEncodedEntryUri ( bucketDest , keyDest ) ;
57+ var uri = conf . RS_HOST + '/move/' + encodedEntryURISrc + '/' + encodedEntryURIDest + '/force/' + force ;
58+ var digest = util . generateAccessToken ( uri , null ) ;
59+ rpc . postWithoutForm ( uri , digest , onret ) ;
60+ }
61+
5362Client . prototype . copy = function ( bucketSrc , keySrc , bucketDest , keyDest , onret ) {
5463 var encodedEntryURISrc = getEncodedEntryUri ( bucketSrc , keySrc ) ;
5564 var encodedEntryURIDest = getEncodedEntryUri ( bucketDest , keyDest ) ;
@@ -58,6 +67,16 @@ Client.prototype.copy = function(bucketSrc, keySrc, bucketDest, keyDest, onret)
5867 rpc . postWithoutForm ( uri , digest , onret ) ;
5968}
6069
70+ Client . prototype . forceCopy = function ( bucketSrc , keySrc , bucketDest , keyDest , force , onret ) {
71+
72+ var encodedEntryURISrc = getEncodedEntryUri ( bucketSrc , keySrc ) ;
73+ var encodedEntryURIDest = getEncodedEntryUri ( bucketDest , keyDest ) ;
74+ var uri = conf . RS_HOST + '/copy/' + encodedEntryURISrc + '/' + encodedEntryURIDest + '/force/' + force ;
75+ var digest = util . generateAccessToken ( uri , null ) ;
76+ rpc . postWithoutForm ( uri , digest , onret ) ;
77+ }
78+
79+
6180Client . prototype . fetch = function ( url , bucket , key , onret ) {
6281 var bucketUri = getEncodedEntryUri ( bucket , key ) ;
6382 var fetchUrl = util . urlsafeBase64Encode ( url ) ;
@@ -94,8 +113,15 @@ function EntryPathPair(src, dest) {
94113 this . dest = dest || null ;
95114}
96115
97- EntryPathPair . prototype . toStr = function ( op ) {
98- return 'op=/' + op + '/' + this . src . encode ( ) + '/' + this . dest . encode ( ) + '&' ;
116+ EntryPathPair . prototype . toStr = function ( op , force ) {
117+ if ( typeof ( force ) == 'undefined' ) {
118+
119+ return 'op=/' + op + '/' + this . src . encode ( ) + '/' + this . dest . encode ( ) + '&' ;
120+
121+ } else {
122+
123+ return 'op=/' + op + '/' + this . src . encode ( ) + '/' + this . dest . encode ( ) + '/force/' + force + '&' ;
124+ }
99125}
100126
101127function BatchItemRet ( error , code ) {
@@ -121,10 +147,23 @@ Client.prototype.batchMove = function(entries, onret) {
121147 fileHandle ( 'move' , entries , onret ) ;
122148}
123149
150+ Client . prototype . forceBatchMove = function ( entries , force , onret ) {
151+
152+ fileHandleForce ( 'move' , entries , force , onret ) ;
153+
154+ }
155+
124156Client . prototype . batchCopy = function ( entries , onret ) {
125157 fileHandle ( 'copy' , entries , onret ) ;
126158}
127159
160+ Client . prototype . forceBatchCopy = function ( entries , force , onret ) {
161+
162+ fileHandleForce ( 'copy' , entries , force , onret ) ;
163+
164+ }
165+
166+
128167function fileHandle ( op , entries , onret ) {
129168 var body = '' ;
130169 for ( var i in entries ) {
@@ -136,6 +175,18 @@ function fileHandle(op, entries, onret) {
136175 rpc . postWithForm ( uri , body , digest , onret ) ;
137176}
138177
178+ function fileHandleForce ( op , entries , force , onret ) {
179+ var body = '' ;
180+ for ( var i in entries ) {
181+ body += entries [ i ] . toStr ( op , force ) ;
182+ }
183+
184+ console . log ( body ) ;
185+ var uri = conf . RS_HOST + '/batch' ;
186+ var digest = util . generateAccessToken ( uri , body ) ;
187+ rpc . postWithForm ( uri , body , digest , onret ) ;
188+ }
189+
139190function getEncodedEntryUri ( bucket , key ) {
140191 return util . urlsafeBase64Encode ( bucket + ( key ? ':' + key : '' ) ) ;
141192}
0 commit comments