def copy_an_outgoing_object(srcd, dstd, prefix, bigdata = False): try: sData,sMeta,sAuxi,sDone,sMdon = ryw.get_store_paths(srcd, prefix) dData,dMeta,dAuxi,dDone,dMdon = ryw.get_store_paths(dstd, prefix) # # first deal with data. # if not bigdata: shutil.copytree(sData, dData) #logging.debug('copy_an_outgoing_object: copied data: ' + # sData + ' -> ' + dData) else: #logging.debug('copy_an_outgoing_object: skipping data: ' + # sData) #ryw.give_news('copy_an_outgoing_object: skipping data: ' + # sData, logging.info) pass # # now copy metadata. # shutil.copyfile(sMeta, dMeta) #logging.debug('copy_an_outgoing_object: copied metadata: ' + # sMeta + ' -> ' + dMeta) # # copy the _AUXI directory, skipping big files in them. # if sAuxi and os.path.exists(sAuxi): success = copy_tree_diff_common(sAuxi, dAuxi, copy_tree_diff_file_repo, copy_tree_diff_dir_simple) if not success: raise 'copy_tree_diff_common failed.' #logging.debug('copy_an_outgoing_object: copied AUXI files: ' + # sAuxi + ' -> ' + dAuxi) # # place a done flag. # if not bigdata: shutil.copyfile(sDone, dDone) #logging.debug('copy_an_outgoing_object: placed DONE flag: ' + # sDone + ' -> ' + dDone) else: shutil.copyfile(sDone, dMdon) #logging.debug('copy_an_outgoing_object: placed MDON flag: ' + # sDone + ' -> ' + dMdon) #ryw.give_news('copy_an_outgoing_object: placed MDON flag: ' + # sDone + ' -> ' + dMdon, logging.info) success = True except: ryw.give_bad_news('copy_an_outgoing_object: failed: ' + srcd + ' ' + dstd + ' ' + prefix + ' ' + repr(bigdata), logging.critical) success = False ryw.cleanup_partial_repo_dir(dstd, [prefix]) return success
def process_repo_dir(srcd, dstd, copyFileFunc, copyDirFunc): #check_village_log('test process_repo_dir') success,entries,regularEntries,prefixes = get_repo_dir_entries(srcd) goodPrefixes = ryw.cleanup_partial_repo_dir(srcd, prefixes) # logging.debug('goodPrefixes: ' + repr(goodPrefixes)) # logging.debug('regular: ' + repr(regularEntries)) success = True for regular in regularEntries: srcName = os.path.join(srcd, regular) dstName = os.path.join(dstd, regular) logging.debug(' regular is: ' + regular) thisSuccess = copy_tree_diff_common(srcName, dstName, copyFileFunc, copyDirFunc) success = success and thisSuccess for prefix in goodPrefixes: success,isBig = is_big_data(srcd, prefix) if not success: ryw.give_bad_news( 'process_repo_dir: failed to determine data size: '+srcd, logging.warning) continue thisSuccess = copy_an_outgoing_object(srcd, dstd, prefix, bigdata = isBig) success = success and thisSuccess return success