// dir_sync_make.cpp // sync_make // Created by housisong on 2019-10-01. /* The MIT License (MIT) Copyright (c) 2019-2023 HouSisong Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dir_sync_make.h" #if (_IS_NEED_DIR_DIFF_PATCH) #include "../../dirDiffPatch/dir_diff/dir_diff_tools.h" #include "sync_make_hash_clash.h" #include "sync_info_make.h" using namespace hdiff_private; using namespace sync_private; static void getRefList(const std::vector& newList, std::vector& out_newSizeList){ out_newSizeList.assign(newList.size(),0); for (size_t newi=0; newi0)); assert(kMaxOpenFileNumber>=kMaxOpenFileNumber_limit_min); kMaxOpenFileNumber-=2; // for out_hsyni_file & out_hsynz_file const std::vector& newList=newManifest.pathList; std::vector newSizeList; std::vector newExecuteList; //for linux etc for (size_t newi=0; newiisExecuteFile(newList[newi]))) newExecuteList.push_back(newi); } getRefList(newList,newSizeList); TNewDataSyncInfo_dir dirInfo={0}; std::vector dirInfoSavedData; dirInfo.dir_newPathCount=newList.size(); dirInfo.dir_newNameList_isCString=hpatch_FALSE; dirInfo.dir_utf8NewNameList=newList.data(); dirInfo.dir_utf8NewRootPath=newManifest.rootPath.c_str(); dirInfo.dir_newSizeList=newSizeList.data(); dirInfo.dir_newExecuteCount=newExecuteList.size(); dirInfo.dir_newExecuteIndexList=newExecuteList.data(); TNewDataSyncInfo_dirWithHead_saveTo(&dirInfo,dirInfoSavedData); CFileResHandleLimit resLimit(kMaxOpenFileNumber,newList.size()+1); hpatch_StreamPos_t maxNewSize=dirInfoSavedData.size(); { resLimit.addBufRes(dirInfoSavedData.data(),dirInfoSavedData.size()); for (size_t i=0; imaxNewSize)?newSize:maxNewSize; resLimit.addRes(newList[i],newSize); } } if (kSyncBlockSize>maxNewSize){ kSyncBlockSize=(uint32_t)maxNewSize; if (kSyncBlockSizestreamSize,kSyncBlockSize, strongChecksumPlugin->checksumByteSize()*8); listener->syncRefInfo(newManifest.rootPath.c_str(),newList.size(),newRefStream.stream->streamSize, kSyncBlockSize,isSafeHashClash); checkv(isSafeHashClash); //warning as error CNewDataSyncInfo newDataSyncInfo(strongChecksumPlugin,compressPlugin, newRefStream.stream->streamSize,kSyncBlockSize,kSafeHashClashBit); newDataSyncInfo.isDirSyncInfo=hpatch_TRUE; newDataSyncInfo.dirInfo=dirInfo; newDataSyncInfo.dirInfoSavedSize=dirInfoSavedData.size(); CFileStreamOutput out_newSyncInfo(out_hsyni_file,~(hpatch_StreamPos_t)0); CFileStreamOutput out_newSyncData(out_hsynz_file,~(hpatch_StreamPos_t)0); _private_create_sync_data(&newDataSyncInfo, newRefStream.stream,&out_newSyncInfo.base, &out_newSyncData.base, compressPlugin,hsynzPlugin,threadNum); } #endif