From e7ebaa85cb7c9dcab3e57892e18e0611b9b8d83c Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 12 Nov 2022 00:15:45 +1100 Subject: [PATCH] Fix nodelist crc's that have 8 chars --- app/Classes/FTN/Tic.php | 4 ++-- app/Jobs/NodelistImport.php | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index 5c83bcd..86ec013 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -188,8 +188,8 @@ class Tic extends FTNBase throw new \Exception(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$fo->size,$fo->fullname,$y)); // Validate CRC - if (sprintf('%x',$fo->crc) !== ($y=hash_file('crc32b',$x))) - throw new \Exception(sprintf('TIC file CRC [%x] doesnt match file [%s] (%s)',$fo->crc,$fo->fullname,$y)); + if (sprintf('%08x',$fo->crc) !== ($y=hash_file('crc32b',$x))) + throw new \Exception(sprintf('TIC file CRC [%08x] doesnt match file [%s] (%s)',$fo->crc,$fo->fullname,$y)); // Validate Password if ($this->pw !== ($y=$this->from->session('ticpass'))) diff --git a/app/Jobs/NodelistImport.php b/app/Jobs/NodelistImport.php index ab6facb..0c1c285 100644 --- a/app/Jobs/NodelistImport.php +++ b/app/Jobs/NodelistImport.php @@ -378,10 +378,13 @@ class NodelistImport implements ShouldQueue Address::whereIN('id',$remove->pluck('id')->toArray())->update(['active'=>FALSE]); Address::whereIN('id',$remove->pluck('id')->toArray())->delete(); - if (crc16(substr($tocrc,0,-3)) == $file_crc) + if ($x=crc16(substr($tocrc,0,-3)) == $file_crc) { + Log::info(sprintf('%s:Committing nodelist',self::LOGKEY)); DB::commit(); - else + } else { + Log::error(sprintf('%s:Rolling back nodelist, CRC doesnt match [%s](%s)',self::LOGKEY,$x,$file_crc)); DB::rollBack(); + } fclose($fh);