File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
emhttp/plugins/dynamix/include Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -147,11 +147,17 @@ private function installNewKey($key)
147147 $ KeyInstaller ->installKey ($ key );
148148 }
149149
150- private function writeJsonFile ($ file , $ data )
150+ private function writeJsonFile ($ file , $ data, $ append = false )
151151 {
152- if (!is_dir (dirname ($ file ))) { // prevents errors when directory doesn't exist
152+ if (!is_dir (dirname ($ file ))) {
153153 mkdir (dirname ($ file ));
154154 }
155+
156+ if ($ append && file_exists ($ file )) {
157+ $ existing = json_decode (file_get_contents ($ file ), true ) ?: [];
158+ $ data = array_merge_recursive ($ existing , $ data );
159+ }
160+
155161 file_put_contents ($ file , json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
156162 }
157163
@@ -188,7 +194,9 @@ public function check(bool $forceCheck = false)
188194 '/tmp/ReplaceKey/error.json ' ,
189195 [
190196 'error ' => 'Failed to retrieve latest key after getting a `hasNewerKeyfile` in the validation response. ' ,
191- ]
197+ 'ts ' => time (),
198+ ],
199+ true ,
192200 );
193201 return ;
194202 }
You can’t perform that action at this time.
0 commit comments