update(); } public function update() { $v = $this->getVersionFile(); if($v && isset($v['commit_hash']) && $v['commit_hash'] == exec('git rev-parse HEAD') && \App\StatusHashtag::whereNull('profile_id')->count() == 0) { $this->info('No updates found.'); return; } $bar = $this->output->createProgressBar(\App\StatusHashtag::whereNull('profile_id')->count()); \App\StatusHashtag::whereNull('profile_id')->with('status')->chunk(50, function($sh) use ($bar) { foreach($sh as $status_hashtag) { if(!$status_hashtag->status) { $status_hashtag->delete(); } else { $status_hashtag->profile_id = $status_hashtag->status->profile_id; $status_hashtag->save(); } $bar->advance(); } }); $this->updateVersionFile(); $bar->finish(); } protected function getVersionFile() { $path = storage_path('app/version.json'); return is_file($path) ? json_decode(file_get_contents($path), true) : false; } protected function updateVersionFile() { $path = storage_path('app/version.json'); $contents = [ 'commit_hash' => exec('git rev-parse HEAD'), 'version' => config('pixelfed.version'), 'timestamp' => date('c') ]; $json = json_encode($contents, JSON_PRETTY_PRINT); file_put_contents($path, $json); } }