Skip to content

Commit 59eda08

Browse files
committed
Clean up *.DS_Store files and prevent them from being deployed
See https://www.woltlab.com/community/thread/315887/
1 parent 9c39af6 commit 59eda08

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

com.woltlab.wcf/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \
9595
<instruction type="userOption"/>
9696

9797
<instruction type="script">acp/update_com.woltlab.wcf_6.2_userCoverPhoto.php</instruction>
98+
<instruction type="script">acp/update_com.woltlab.wcf_6.2_cleanUpDsStore.php</instruction>
9899
</instructions>
99100

100101
<instructions type="update" fromversion="6.2.0 RC 2">
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace wcf\acp;
4+
5+
use wcf\system\application\ApplicationHandler;
6+
use wcf\system\WCF;
7+
8+
// Purges any `.DS_Store` (or derivates) files that had been accidentially
9+
// deployed in the past. The `Installer` class was also modified to filter out
10+
// these files in the future.
11+
12+
$sql = "SELECT *
13+
FROM wcf1_package_installation_file_log
14+
WHERE filename LIKE ?";
15+
$statement = WCF::getDB()->prepare($sql);
16+
$statement->execute(['%.DS_Store']);
17+
18+
while ($row = $statement->fetchArray()) {
19+
$application = ApplicationHandler::getInstance()->getApplication($row['application']);
20+
\assert($application !== null);
21+
22+
$pathname = \WCF_DIR . $application->getPackage()->packageDir . $row['filename'];
23+
if (\file_exists($pathname)) {
24+
\unlink($pathname);
25+
}
26+
}
27+
28+
$sql = "DELETE FROM wcf1_package_installation_file_log
29+
WHERE filename LIKE ?";
30+
$statement = WCF::getDB()->prepare($sql);
31+
$statement->execute(['%.DS_Store']);

wcfsetup/install/files/lib/system/setup/Installer.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ protected function install()
150150
// remove trailing slash
151151
$directories[] = FileUtil::removeTrailingSlash($file['filename']);
152152
} else {
153+
if (\str_ends_with($file['filename'], '.DS_Store')) {
154+
continue;
155+
}
156+
153157
$files[$index] = $file['filename'];
154158
}
155159
}

0 commit comments

Comments
 (0)