refactor(jobs): hapus manajemen izin file (chmod, chown, chgrp)
Perubahan yang dilakukan: - ExportStatementJob.php: - Menghapus kode chmod(0777), chown, dan chgrp pada direktori basePath dan accountPath. - Menyederhanakan fungsi exportToCsv() dengan hanya menggunakan Storage::makeDirectory() tanpa pengaturan izin manual. - ExportStatementPeriodJob.php: - Menghapus proses chmod(0777), chown, dan chgrp dari generatePdf() dan exportToCsv(). - Mempertahankan mkdir() dengan parameter 0777 untuk kompatibilitas permission default, tanpa manipulasi ownership. - Menghapus pengecekan posix_getuid() dan function_exists() yang sebelumnya digunakan untuk memvalidasi chown. - GenerateMultiAccountPdfJob.php: - Menghapus semua proses chmod(0777), chown, dan chgrp pada direktori penyimpanan. - Menyederhanakan fungsi generateAccountPdf() dengan menghilangkan pengaturan ownership manual. Tujuan perubahan: - Menyederhanakan kode dan menghilangkan proses manajemen izin file yang tidak perlu. - Menghilangkan ketergantungan pada fungsi sistem operasi terkait chmod, chown, dan chgrp. - Mengurangi kompleksitas dan meminimalkan potensi error saat runtime. - Meningkatkan portabilitas aplikasi agar dapat berjalan di berbagai environment seperti Linux, Windows, dan Docker tanpa kendala perizinan file. - Menghilangkan risiko keamanan akibat perubahan ownership file secara manual. - Mempermudah deployment dan maintenance dengan kode yang lebih clean dan aman. Catatan: - Pembuatan direktori tetap menggunakan Laravel Storage facade atau mkdir() untuk kebutuhan tertentu. - Tidak ada perubahan pada logika bisnis utama dari proses export PDF dan CSV. - Semua fitur export tetap berjalan seperti sebelumnya tanpa pengaturan file permission manual.
This commit is contained in:
@@ -156,7 +156,7 @@
|
||||
'description' => $this->generateNarrative($item),
|
||||
'end_balance' => $runningBalance,
|
||||
'actual_date' => $actualDate,
|
||||
'recipt_no' => $item->ft?->recipt_no ?? '-',
|
||||
'recipt_no' => $item->ft?->recipt_no ?? '-',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
@@ -371,31 +371,9 @@
|
||||
if (!empty($this->client)) {
|
||||
// Di fungsi exportToCsv untuk basePath
|
||||
Storage::disk($this->disk)->makeDirectory($basePath);
|
||||
// Tambahkan permission dan ownership setelah membuat directory
|
||||
if ($this->disk === 'local') {
|
||||
$fullPath = storage_path("app/{$basePath}");
|
||||
if (is_dir($fullPath)) {
|
||||
chmod($fullPath, 0777);
|
||||
if (function_exists('chown') && posix_getuid() === 0) {
|
||||
@chown(dirname($fullPath), 'www-data'); // Gunakan www-data instead of root
|
||||
@chgrp(dirname($fullPath), 'www-data');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Untuk accountPath
|
||||
Storage::disk($this->disk)->makeDirectory($accountPath);
|
||||
// Tambahkan permission dan ownership setelah membuat directory
|
||||
if ($this->disk === 'local') {
|
||||
$fullPath = storage_path("app/{$accountPath}");
|
||||
if (is_dir($fullPath)) {
|
||||
chmod($fullPath, 0777);
|
||||
if (function_exists('chown') && posix_getuid() === 0) {
|
||||
@chown(dirname($fullPath), 'www-data'); // Gunakan www-data instead of root
|
||||
@chgrp(dirname($fullPath), 'www-data');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filePath = "{$accountPath}/{$this->fileName}";
|
||||
|
||||
Reference in New Issue
Block a user