Fix nodelist crc's that have 8 chars

This commit is contained in:
Deon George 2022-11-12 00:15:45 +11:00
parent b158bb5a7d
commit e7ebaa85cb
2 changed files with 7 additions and 4 deletions

View File

@ -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)); throw new \Exception(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$fo->size,$fo->fullname,$y));
// Validate CRC // Validate CRC
if (sprintf('%x',$fo->crc) !== ($y=hash_file('crc32b',$x))) if (sprintf('%08x',$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)); throw new \Exception(sprintf('TIC file CRC [%08x] doesnt match file [%s] (%s)',$fo->crc,$fo->fullname,$y));
// Validate Password // Validate Password
if ($this->pw !== ($y=$this->from->session('ticpass'))) if ($this->pw !== ($y=$this->from->session('ticpass')))

View File

@ -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())->update(['active'=>FALSE]);
Address::whereIN('id',$remove->pluck('id')->toArray())->delete(); 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(); DB::commit();
else } else {
Log::error(sprintf('%s:Rolling back nodelist, CRC doesnt match [%s](%s)',self::LOGKEY,$x,$file_crc));
DB::rollBack(); DB::rollBack();
}
fclose($fh); fclose($fh);