- if [[ -n "$pathFileIn1" ]]; then
- # 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;
+ ## Get file hash
+ fhash="$(get_sha256_digest "$pathFileIn"; )";
+
+ ## Get stored OTS path if possible.
+ if ! path_stored_ots="$(get_oldest_stored_ots_path "$fhash"; )"; then
+ yell "STATUS:No stored OTS found. No action taken for:${pathFileIn}";
+ return 0;
+ fi;
+ vbm "STATUS:A stored OTS found with matching hash for provided file ${pathFileIn}.";
+ blk_stored="$(get_ots_oldestblock "$path_stored_ots"; )";
+ vbm "STATUS:The stored OTS file has block number ${blk_stored}.";
+
+ ## Check for OTS file accompanying provided file
+ if [[ -f "${pathFileIn}.ots" ]]; then
+ vbm "STATUS:An OTS file is next to provided file ${pathFileIn}.";
+ blk_provid="$(get_ots_oldestblock "${pathFileIn}.ots"; )";
+ vbm "STATUS:The provided file's OTS file has block number ${blk_provid}";
+ if [[ "$blk_stored" -lt "$blk_provid" ]]; then
+ vbm "STATUS:An older timestamp in OTS store found. Replacing ${pathFileIn}.ots (block ${blk_provid}) with ${path_stored_ots} (block ${blk_stored}).";
+ if [[ ! -f "${pathFileIn}.ots.baku" ]]; then
+ must mv "${pathFileIn}.ots" "${pathFileIn}.ots.baku" && \
+ vbm "STATUS:Backed up existing OTS file.";