From 9237edb22811f0912919e9af5bcaa54609d900b9 Mon Sep 17 00:00:00 2001 From: "allen.yan" Date: Wed, 25 Jun 2025 10:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=96=AE=E6=A9=9F=E7=89=88=20v0.0.10=202025062?= =?UTF-8?q?5=20song=5Flibrary=5Fcache=20id=20=E4=B8=8D=E6=AD=A3=E7=A2=BA?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 ++ app/Console/Commands/CompareSongFiles.php | 30 +++++++++++++ app/Console/Commands/TestFtpConnection.php | 40 +++++++++++++++++ app/Models/SongLibraryCache.php | 1 + composer.json | 1 + composer.lock | 52 +++++++++++++++++++++- config/filesystems.php | 11 +++++ 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/CompareSongFiles.php create mode 100644 app/Console/Commands/TestFtpConnection.php diff --git a/.env.example b/.env.example index 3ddea9b..6a53c1d 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,10 @@ APP_LOCALE=zh-tw APP_FALLBACK_LOCALE=zh-tw APP_FAKER_LOCALE=zh_TW +FTP_HOST=192.168.11.16 +FTP_USERNAME=svr +FTP_PASSWORD=svr + APP_MAINTENANCE_DRIVER=file # APP_MAINTENANCE_STORE=database diff --git a/app/Console/Commands/CompareSongFiles.php b/app/Console/Commands/CompareSongFiles.php new file mode 100644 index 0000000..bea320f --- /dev/null +++ b/app/Console/Commands/CompareSongFiles.php @@ -0,0 +1,30 @@ +info("🔼 上傳中..."); + if (!$disk->put($testFile, $testContent)) { + return $this->error("❌ 上傳失敗"); + } + + // 嘗試讀取 + $this->info("📥 下載檢查..."); + $content = $disk->get($testFile); + if ($content !== $testContent) { + return $this->error("❌ 檔案內容不符"); + } + + // 嘗試刪除 + $this->info("🗑️ 刪除測試檔案..."); + if (!$disk->delete($testFile)) { + return $this->error("❌ 刪除失敗"); + } + + $this->info("✅ FTP 測試成功!"); + } +} \ No newline at end of file diff --git a/app/Models/SongLibraryCache.php b/app/Models/SongLibraryCache.php index d029827..9ae82c5 100644 --- a/app/Models/SongLibraryCache.php +++ b/app/Models/SongLibraryCache.php @@ -16,6 +16,7 @@ class SongLibraryCache extends Model // 可寫入的欄位(可依需要擴充) protected $fillable = [ + 'song_id', 'song_name', 'song_simplified', 'phonetic_abbr', diff --git a/composer.json b/composer.json index 4c436db..a639b78 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "laravel/framework": "^12.0", "laravel/sanctum": "^4.0", "laravel/tinker": "^2.10.1", + "league/flysystem-ftp": "^3.29", "livewire/livewire": "^3.4", "livewire/volt": "^1.7.0", "maatwebsite/excel": "^3.1", diff --git a/composer.lock b/composer.lock index e7b111d..1cb64ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3d96136c4b2709b3558d30eafa66bcfc", + "content-hash": "2cd258dd8d67caabf878279f2818cfbc", "packages": [ { "name": "brick/math", @@ -2169,6 +2169,56 @@ }, "time": "2024-10-08T08:58:34+00:00" }, + { + "name": "league/flysystem-ftp", + "version": "3.29.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-ftp.git", + "reference": "17e8e422cb43a7fefa06ec8ddf36ee8ec936d138" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-ftp/zipball/17e8e422cb43a7fefa06ec8ddf36ee8ec936d138", + "reference": "17e8e422cb43a7fefa06ec8ddf36ee8ec936d138", + "shasum": "" + }, + "require": { + "ext-ftp": "*", + "league/flysystem": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\Ftp\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "FTP filesystem adapter for Flysystem.", + "keywords": [ + "Flysystem", + "file", + "files", + "filesystem", + "ftp", + "ftpd" + ], + "support": { + "source": "https://github.com/thephpleague/flysystem-ftp/tree/3.29.0" + }, + "time": "2024-06-12T09:46:12+00:00" + }, { "name": "league/flysystem-local", "version": "3.29.0", diff --git a/config/filesystems.php b/config/filesystems.php index c8c8342..6c9dacf 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -60,6 +60,17 @@ return [ 'report' => false, ], + 'ftp_test' => [ + 'driver' => 'ftp', + 'host' => env('FTP_HOST', '192.168.11.16'), + 'username' => env('FTP_USERNAME', 'your_username'), + 'password' => env('FTP_PASSWORD', 'your_password'), + 'port' => 21, + 'root' => '/', // 或指定資料夾 + 'passive' => true, + 'ssl' => false, + 'timeout' => 30, + ], ], /*