From 67747c062a99dd05946db0d8c75391a068038336 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 16 Nov 2023 20:39:48 +1100 Subject: [PATCH] Add mtime to receiving filename, so that we dont have name clashes with systems that use the same archive name for our host --- app/Classes/File.php | 4 ++-- app/Classes/File/Item.php | 2 +- app/Console/Commands/PacketProcess.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Classes/File.php b/app/Classes/File.php index 7ceb630..1279c4f 100644 --- a/app/Classes/File.php +++ b/app/Classes/File.php @@ -102,13 +102,13 @@ class File extends FileBase implements \Iterator } /** - * Return the name of the file, without a node ID prefix + * Return the name of the file, without a node ID, mtime prefix * * @return string */ public function rawName(): string { - return preg_replace('/^[0-9A-F]{4}-/','',$this->getFilename()); + return preg_replace('/^[0-9A-F]{4}-([0-9]+)-]/','',$this->getFilename()); } /** diff --git a/app/Classes/File/Item.php b/app/Classes/File/Item.php index bc52403..abbef06 100644 --- a/app/Classes/File/Item.php +++ b/app/Classes/File/Item.php @@ -36,7 +36,7 @@ final class Item extends Receive return Storage::disk(config('fido.local_disk'))->exists($this->rel_name); case 'pref_name': - return sprintf('%04X-%s',$this->ao->id,$this->recvas); + return sprintf('%04X-%d-%s',$this->ao->id,$this->recvmtime,$this->recvas); case 'rel_name': return sprintf('%s/%s',config('fido.dir'),$this->pref_name); case 'full_name': diff --git a/app/Console/Commands/PacketProcess.php b/app/Console/Commands/PacketProcess.php index 3365e31..9e66f17 100644 --- a/app/Console/Commands/PacketProcess.php +++ b/app/Console/Commands/PacketProcess.php @@ -49,7 +49,7 @@ class PacketProcess extends Command if ($this->argument('ftn')) { $a = Address::findFTN($this->argument('ftn')); - } elseif (preg_match('/^(([0-9]+)-)+/',$this->argument('file'),$m)) { + } elseif (preg_match('/^(([0-9A-F]+)-([0-9]+))+/',$this->argument('file'),$m)) { $a = Address::findOrFail(hexdec($m[2])); } else {