1
1
import functools
2
2
import logging
3
+ import os
4
+ import shutil
3
5
import sys
4
6
5
7
import click
6
8
import click_log
7
9
10
+ from ..utils import expand_path
8
11
from .. import __version__
9
12
from .. import BUGTRACKER_HOME
10
13
@@ -198,6 +201,9 @@ def discover(ctx, pairs, max_workers, list):
198
201
config = ctx .config
199
202
wq = WorkerQueue (max_workers )
200
203
204
+ pairs_a = set ()
205
+ pairs_b = set ()
206
+ pairs_b_path = {}
201
207
with wq .join ():
202
208
for pair_name in (pairs or config .pairs ):
203
209
pair = config .get_pair (pair_name )
@@ -210,6 +216,22 @@ def discover(ctx, pairs, max_workers, list):
210
216
list_collections = list ,
211
217
))
212
218
wq .spawn_worker ()
219
+ if pair .config_b ['type' ] == 'filesystem' :
220
+ for key in _DiscoverResult (pair .config_b )._discovered .keys ():
221
+ pairs_b .add (key )
222
+ pairs_b_path [key ] = (pair .config_b ["path" ], pair .name )
223
+ pairs_a = pairs_a .union (set (_DiscoverResult (pair .config_a )._discovered .keys ()))
224
+
225
+ for dele in pairs_b - pairs_a :
226
+ path = pairs_b_path [dele ][0 ] + '/' + dele
227
+ if not os .path .islink (path ):
228
+ shutil .rmtree (path , ignore_errors = True )
229
+ path = expand_path (os .path .join (config .general ['status_path' ], pairs_b_path [dele ][1 ] + '/' + dele ))
230
+ for m in ('items' , 'metadata' ):
231
+ try :
232
+ os .remove (path + '.' + m )
233
+ except :
234
+ pass
213
235
214
236
215
237
@app .command ()
@@ -243,3 +265,5 @@ def repair(ctx, collection, repair_unsafe_uid):
243
265
click .confirm ('Do you want to continue?' , abort = True )
244
266
repair_collection (ctx .config , collection ,
245
267
repair_unsafe_uid = repair_unsafe_uid )
268
+
269
+ from .discover import _DiscoverResult
0 commit comments