Make filename unique for each area, rename column to name/lname for files
This commit is contained in:
parent
0eca20ebdd
commit
b8534d8598
@ -81,7 +81,7 @@ class Tic extends FTNBase
|
|||||||
public function isNodelist(): bool
|
public function isNodelist(): bool
|
||||||
{
|
{
|
||||||
return (($this->fo->nodelist_filearea_id === $this->fo->filearea->domain->filearea_id)
|
return (($this->fo->nodelist_filearea_id === $this->fo->filearea->domain->filearea_id)
|
||||||
&& (preg_match(str_replace(['.','?'],['\.','.'],'#^'.$this->fo->filearea->domain->nodelist_filename.'$#i'),$this->fo->file)));
|
&& (preg_match(str_replace(['.','?'],['\.','.'],'#^'.$this->fo->filearea->domain->nodelist_filename.'$#i'),$this->fo->name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +101,7 @@ class Tic extends FTNBase
|
|||||||
$result->put('ORIGIN',$fo->path->first()->ftn3d);
|
$result->put('ORIGIN',$fo->path->first()->ftn3d);
|
||||||
$result->put('FROM',$sysaddress->ftn3d);
|
$result->put('FROM',$sysaddress->ftn3d);
|
||||||
$result->put('TO',$ao->ftn3d);
|
$result->put('TO',$ao->ftn3d);
|
||||||
$result->put('FILE',$fo->file);
|
$result->put('FILE',$fo->name);
|
||||||
$result->put('SIZE',$fo->size);
|
$result->put('SIZE',$fo->size);
|
||||||
if ($fo->description)
|
if ($fo->description)
|
||||||
$result->put('DESC',$fo->description);
|
$result->put('DESC',$fo->description);
|
||||||
@ -176,7 +176,7 @@ class Tic extends FTNBase
|
|||||||
if (! Storage::disk('local')->exists($x=sprintf('%s/%s-%s',config('app.fido'),$hex,$matches[2])))
|
if (! Storage::disk('local')->exists($x=sprintf('%s/%s-%s',config('app.fido'),$hex,$matches[2])))
|
||||||
throw new FileNotFoundException(sprintf('File not found? [%s]',$x));
|
throw new FileNotFoundException(sprintf('File not found? [%s]',$x));
|
||||||
|
|
||||||
$this->fo->{$k} = $matches[2];
|
$this->fo->name = $matches[2];
|
||||||
$this->fo->fullname = $x;
|
$this->fo->fullname = $x;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -191,8 +191,10 @@ class Tic extends FTNBase
|
|||||||
case 'pw':
|
case 'pw':
|
||||||
$pw = $matches[2];
|
$pw = $matches[2];
|
||||||
|
|
||||||
case 'desc':
|
|
||||||
case 'lfile':
|
case 'lfile':
|
||||||
|
$this->fo->lname = $matches[2];
|
||||||
|
|
||||||
|
case 'desc':
|
||||||
case 'magic':
|
case 'magic':
|
||||||
case 'replaces':
|
case 'replaces':
|
||||||
case 'size':
|
case 'size':
|
||||||
|
@ -116,7 +116,7 @@ class Item
|
|||||||
return $this->file_name;
|
return $this->file_name;
|
||||||
|
|
||||||
case 'sendas':
|
case 'sendas':
|
||||||
return $this->file_name ? basename($this->file_name) : $this->filemodel->file;
|
return $this->file_name ? basename($this->file_name) : $this->filemodel->name;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception('Unknown key: '.$key);
|
throw new Exception('Unknown key: '.$key);
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\File as FileFacade;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Rennokki\QueryCache\Traits\QueryCacheable;
|
use Rennokki\QueryCache\Traits\QueryCacheable;
|
||||||
@ -161,7 +159,7 @@ class File extends Model
|
|||||||
|
|
||||||
public function getFullStoragePathAttribute(): string
|
public function getFullStoragePathAttribute(): string
|
||||||
{
|
{
|
||||||
return sprintf('%04X/%s',$this->filearea_id,$this->file);
|
return sprintf('%04X/%s',$this->filearea_id,$this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* METHODS */
|
/* METHODS */
|
||||||
|
34
database/migrations/2023_06_23_170537_unique_filenames.php
Normal file
34
database/migrations/2023_06_23_170537_unique_filenames.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// delete from files where id in (130,110,25,49,50,51,52,53,73,105,4,44,60,83,85,63,88,90,66,68,70,72,75,78,80,123,124,127,1,102,104,107,109,113,115,117,2,119)
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE files RENAME COLUMN file to name');
|
||||||
|
DB::statement('ALTER TABLE files RENAME COLUMN lfile to lname');
|
||||||
|
|
||||||
|
Schema::table('files',function (Blueprint $table) {
|
||||||
|
$table->unique(['filearea_id','name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user