+ # Check for and store any OTS file attached to provided file
+ if [[ -f "${pathFileIn1}.ots" ]]; then
+ vbm "STATUS:OTS file accompanying provided file found:${pathFileIn1}.ots";
+ cache_ots_file "${pathFileIn1}.ots" && vbm "STATUS:Stored provided file's OTS file.";
+ fi;
+
+ # Get file hash
+ fhash="$(get_sha256_digest "$pathFileIn1"; )";
+ if path_stored_ots="$(get_oldest_stored_ots_path "$fhash"; )"; then
+ vbm "STATUS:Stored OTS found with matching hash.";
+ blk_stored="$(get_ots_oldestblock "$path_stored_ots"; )";
+ vbm "STATUS:Stored OTS file has block number ${blk_stored}.";
+ if [[ -f "${pathFileIn1}.ots" ]]; then
+ vbm "STATUS:An OTS file is next to provided file.";
+ blk_provid="$(get_ots_oldestblock "${pathFileIn1}.ots"; )";
+ vbm "STATUS:Provided file's OTS file has block number ${blk_provid}";
+ if [[ "$blk_stored" -lt "$blk_provid" ]]; then
+ vbm "STATUS:Older timestamp in OTS store found. Replacing ${pathFileIn1} (block ${blk_provid}) with ${path_stored_ots} (block ${blk_stored}).";
+ #must mv "$pathFileIn1" "${pathFileIn1}.baku";
+ #must cp "$path_stored_ots" "$pathFileIn1";
+ else
+ yell "STATUS:Stored OTS file (block ${blk_stored}) is not older than provided file's OTS file (block ${blk_provid}). No action taken for:${pathFileIn1}";
+ fi;
+ else
+ vbm "STATUS:Stored OTS file found with digest matching provided file. Copying ${path_stored_ots} to ${pathFileIn1}.ots";
+ must cp "$path_stored_ots" "${pathFileIn1}.ots";
+ fi;
+ else
+ vbm "STATUS:No stored OTS found. No action taken for:${pathFileIn1}";
+ fi;