Delete shipped apps from both old and new version

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-07-07 11:28:00 +02:00
parent 50bdca3197
commit 1ed9c8ee07
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 24 additions and 6 deletions

View File

@ -903,13 +903,22 @@ EOF;
public function deleteOldFiles() {
$this->silentLog('[info] deleteOldFiles()');
$shippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json';
$shippedAppsFile = $this->baseDir . '/../core/shipped.json';
if(!file_exists($shippedAppsFile)) {
throw new \Exception('core/shipped.json is not available');
}
$newShippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json';
if(!file_exists($newShippedAppsFile)) {
throw new \Exception('core/shipped.json is not available in the new release');
}
// Delete shipped apps
$shippedApps = json_decode(file_get_contents($shippedAppsFile), true);
foreach($shippedApps['shippedApps'] as $app) {
$shippedApps = array_merge(
json_decode(file_get_contents($shippedAppsFile), true)['shippedApps'],
json_decode(file_get_contents($newShippedAppsFile), true)['shippedApps']
);
foreach($shippedApps as $app) {
$this->recursiveDelete($this->baseDir . '/../apps/' . $app);
}

View File

@ -786,13 +786,22 @@ EOF;
public function deleteOldFiles() {
$this->silentLog('[info] deleteOldFiles()');
$shippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json';
$shippedAppsFile = $this->baseDir . '/../core/shipped.json';
if(!file_exists($shippedAppsFile)) {
throw new \Exception('core/shipped.json is not available');
}
$newShippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json';
if(!file_exists($newShippedAppsFile)) {
throw new \Exception('core/shipped.json is not available in the new release');
}
// Delete shipped apps
$shippedApps = json_decode(file_get_contents($shippedAppsFile), true);
foreach($shippedApps['shippedApps'] as $app) {
$shippedApps = array_merge(
json_decode(file_get_contents($shippedAppsFile), true)['shippedApps'],
json_decode(file_get_contents($newShippedAppsFile), true)['shippedApps']
);
foreach($shippedApps as $app) {
$this->recursiveDelete($this->baseDir . '/../apps/' . $app);
}