diff --git a/lib/private/updater.php b/lib/private/updater.php
index d50c2554c75f5531b1e9cc9fe6bde9cae7b180bb..7acd6446ec4e711d72764bb6e285012481332dd1 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -212,8 +212,6 @@ class Updater extends BasicEmitter {
 			\OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
 			$this->emit('\OC\Updater', 'dbUpgrade');
 
-			// TODO: why not do this at the end ?
-			\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
 			$disabledApps = \OC_App::checkAppsRequirements();
 			if (!empty($disabledApps)) {
 				$this->emit('\OC\Updater', 'disabledApps', array($disabledApps));
@@ -227,6 +225,9 @@ class Updater extends BasicEmitter {
 
 			//Invalidate update feed
 			\OC_Appconfig::setValue('core', 'lastupdatedat', 0);
+
+			// only set the final version if everything went well
+			\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
 		}
 	}
 }