From 2bd8c2dba79878269981aac94c1ad51e94b2308e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Jul 2021 14:18:15 +0200 Subject: [PATCH] Add files/acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php --- com.woltlab.wcf/package.xml | 7 +-- ...te_com.woltlab.wcf_5.4.3_deleteDsStore.php | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index b6e81d4968..888fa1b456 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -154,10 +154,7 @@ tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \ acp/update_com.woltlab.wcf_5.4_deleteLanguageItems.php - - acptemplates_update.tar - files_update.tar - - + + acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php new file mode 100644 index 0000000000..6c0cefacfa --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php @@ -0,0 +1,52 @@ + + * @package WoltLabSuite\Core + */ + +use wcf\data\application\Application; +use wcf\system\WCF; + +$sql = "SELECT * + FROM wcf1_package_installation_file_log + WHERE filename LIKE ? + OR filename LIKE ?"; +$selectStatement = WCF::getDB()->prepare($sql); +$selectStatement->execute([ + '%/.DS_Store', + '%/._.DS_Store', +]); + +$sql = "DELETE FROM wcf1_package_installation_file_log + WHERE packageID = ? + AND filename = ? + AND application = ?"; +$deleteStatement = WCF::getDB()->prepare($sql); + +while (($row = $selectStatement->fetchArray())) { + $packageDir = Application::getDirectory($row['application']); + $fullPath = $packageDir . $row['filename']; + + if (!\file_exists($fullPath) || !\is_file($fullPath)) { + continue; + } + + if ( + \basename($fullPath) !== '.DS_Store' + && \basename($fullPath) !== '._.DS_Store' + ) { + continue; + } + + \unlink($fullPath); + $deleteStatement->execute([ + $row['packageID'], + $row['filename'], + $row['application'], + ]); +} -- 2.20.1