@@ -515,13 +515,14 @@ def process_info():
515
515
}
516
516
if driver .is_on ('service_backup_db' ):
517
517
from bitdust .storage import backup_fs
518
+ v = backup_fs .total_stats ()
518
519
result ['file' ] = {
519
- 'items' : backup_fs . counter () ,
520
- 'files' : backup_fs . numberfiles () ,
521
- 'files_size ' : backup_fs . sizefiles () ,
522
- 'folders ' : backup_fs . numberfolders () ,
523
- 'folders_size' : backup_fs . sizefolders () ,
524
- 'backups_size' : backup_fs . sizebackups () ,
520
+ 'items' : v [ 'items' ] ,
521
+ 'files' : v [ 'files' ] ,
522
+ 'folders ' : v [ 'folders' ] ,
523
+ 'files_size ' : v [ 'size_files' ] ,
524
+ 'folders_size' : v [ 'size_folders' ] ,
525
+ 'backups_size' : v [ 'size_backups' ] ,
525
526
'customers' : len (backup_fs .known_customers ()),
526
527
}
527
528
if driver .is_on ('service_shared_data' ):
@@ -693,6 +694,7 @@ def network_select(name):
693
694
694
695
def _on_network_disconnected (x ):
695
696
cur_base_dir = deploy .current_base_dir ()
697
+ # TODO: must wait shutdown and init to complete with defered
696
698
shutdowner .shutdown_services ()
697
699
shutdowner .shutdown_local ()
698
700
shutdowner .shutdown_automats ()
@@ -969,6 +971,20 @@ def network_status(suppliers=False, customers=False, cache=False, tcp=False, udp
969
971
i ['queue' ] = len (s .pending_packets )
970
972
sessions .append (i )
971
973
r ['proxy' ]['sessions' ] = sessions
974
+ if driver .is_on ('service_proxy_server' ):
975
+ from bitdust .transport .proxy import proxy_router
976
+ if proxy_router .A ():
977
+ r ['proxy' ]['routes' ] = []
978
+ for v in proxy_router .A ().routes .values ():
979
+ _r = v ['connection_info' ].copy ()
980
+ _r ['contacts' ] = ', ' .join (['{}:{}' .format (c [0 ], c [1 ]) for c in v ['contacts' ]])
981
+ _r ['address' ] = ', ' .join (['{}:{}' .format (a [0 ], a [1 ]) for a in v ['address' ]])
982
+ _r .pop ('id' , None )
983
+ _r .pop ('index' , None )
984
+ r ['proxy' ]['routes' ].append (_r )
985
+ r ['proxy' ]['closed_routes' ] = [(strng .to_text (k ), strng .to_text (v )) for k , v in proxy_router .A ().closed_routes .items ()]
986
+ r ['proxy' ]['acks' ] = len (proxy_router .A ().acks )
987
+ r ['proxy' ]['hosts' ] = ', ' .join ([('{}://{}:{}' .format (strng .to_text (k ), strng .to_text (v [0 ]), strng .to_text (v [1 ]))) for k , v in proxy_router .A ().my_hosts .items ()])
972
988
if dht :
973
989
from bitdust .dht import dht_service
974
990
r ['dht' ] = {}
@@ -2292,7 +2308,7 @@ def file_delete(remote_path):
2292
2308
backup_fs .DeleteLocalDir (settings .getLocalBackupsDir (), pathIDfull )
2293
2309
backup_fs .DeleteByID (pathID , iter = backup_fs .fs (customer_idurl , key_alias ), iterID = backup_fs .fsID (customer_idurl , key_alias ))
2294
2310
backup_fs .Scan (customer_idurl = customer_idurl , key_alias = key_alias )
2295
- backup_fs .Calculate (iterID = backup_fs . fsID ( customer_idurl , key_alias ) )
2311
+ backup_fs .Calculate (customer_idurl = customer_idurl , key_alias = key_alias )
2296
2312
if key_alias != 'master' :
2297
2313
if driver .is_on ('service_shared_data' ):
2298
2314
from bitdust .access import shared_access_coordinator
@@ -2428,33 +2444,17 @@ def file_upload_start(local_path, remote_path, wait_result=False, publish_events
2428
2444
if not pathID :
2429
2445
return ERROR ('path %s was not registered yet' % remote_path )
2430
2446
keyID = my_keys .make_key_id (alias = key_alias , creator_glob_id = parts ['customer' ])
2431
- # customerID = global_id.MakeGlobalID(customer=parts['customer'], key_alias=key_alias)
2432
2447
pathIDfull = packetid .MakeBackupID (keyID , pathID )
2433
2448
if key_alias != 'master' :
2434
2449
if not driver .is_on ('service_shared_data' ):
2435
2450
return ERROR ('service_shared_data() is not started' )
2436
-
2437
-
2438
- # def _restart_active_share(result):
2439
- # if _Debug:
2440
- # lg.args(_DebugLevel, result=result, key_id=keyID, path=path, pathID=pathID)
2441
- # if key_alias != 'master':
2442
- # from bitdust.access import shared_access_coordinator
2443
- # active_share = shared_access_coordinator.get_active_share(keyID)
2444
- # if not active_share:
2445
- # active_share = shared_access_coordinator.SharedAccessCoordinator(key_id=keyID, publish_events=publish_events)
2446
- # active_share.automat('restart')
2447
- # return result
2448
-
2449
2451
if wait_result :
2450
2452
task_created_defer = Deferred ()
2451
2453
tsk = backup_control .StartSingle (
2452
2454
pathID = pathIDfull ,
2453
2455
localPath = local_path ,
2454
2456
keyID = keyID ,
2455
2457
)
2456
- # if key_alias != 'master':
2457
- # tsk.result_defer.addCallback(_restart_active_share)
2458
2458
tsk .result_defer .addCallback (
2459
2459
lambda result : task_created_defer .callback (
2460
2460
OK (
@@ -2470,15 +2470,16 @@ def file_upload_start(local_path, remote_path, wait_result=False, publish_events
2470
2470
)
2471
2471
)
2472
2472
)
2473
- tsk .result_defer .addErrback (lambda result : task_created_defer .callback (ERROR (
2474
- 'uploading task %d for %s failed: %s' % (
2475
- tsk .number ,
2476
- tsk .pathID ,
2477
- result [1 ],
2478
- ),
2479
- api_method = 'file_upload_start' ,
2480
- ), ), )
2481
- backup_fs .Calculate (iterID = backup_fs .fsID (customer_idurl , key_alias ))
2473
+ tsk .result_defer .addErrback (lambda result : task_created_defer .callback (ERROR (result , api_method = 'file_upload_start' )))
2474
+ # tsk.result_defer.addErrback(lambda result: task_created_defer.callback(ERROR(
2475
+ # 'uploading task %d for %s failed: %s' % (
2476
+ # tsk.number,
2477
+ # tsk.pathID,
2478
+ # result,
2479
+ # ),
2480
+ # api_method='file_upload_start',
2481
+ # ), ), )
2482
+ backup_fs .Calculate (customer_idurl = customer_idurl , key_alias = key_alias )
2482
2483
backup_control .SaveFSIndex (customer_idurl , key_alias )
2483
2484
if _Debug :
2484
2485
lg .out (_DebugLevel , 'api.file_upload_start %s with %s, wait_result=True' % (remote_path , pathIDfull ))
@@ -2489,10 +2490,8 @@ def file_upload_start(local_path, remote_path, wait_result=False, publish_events
2489
2490
localPath = local_path ,
2490
2491
keyID = keyID ,
2491
2492
)
2492
- # if key_alias != 'master':
2493
- # tsk.result_defer.addCallback(_restart_active_share)
2494
- tsk .result_defer .addErrback (lambda result : lg .err ('errback from api.file_upload_start.task(%s) failed with %s' % (result [0 ], result [1 ])))
2495
- backup_fs .Calculate (iterID = backup_fs .fsID (customer_idurl , key_alias ))
2493
+ tsk .result_defer .addErrback (lambda result : lg .err ('errback from api.file_upload_start.task() failed with %r' % result ))
2494
+ backup_fs .Calculate (customer_idurl = customer_idurl , key_alias = key_alias )
2496
2495
backup_control .SaveFSIndex (customer_idurl , key_alias )
2497
2496
if _Debug :
2498
2497
lg .out (_DebugLevel , 'api.file_upload_start %s with %s' % (remote_path , pathIDfull ))
0 commit comments