MVC, config: add method to find backup filename (or false if not found)

needed for  https://github.com/opnsense/plugins/issues/1720
This commit is contained in:
Ad Schellevis 2020-03-09 18:41:26 +01:00
parent 5b7268bb17
commit 8f3c89642c

View File

@ -559,6 +559,22 @@ class Config extends Singleton
}
}
/**
* return backup file path if revision exists
* @param $revision revision timestamp (e.g. 1583766095.9337)
* @return bool|string filename when available or false when not found
*/
public function getBackupFilename($revision)
{
$tmp = (float)$revision;
$bckfilename = dirname($this->config_file) . "/backup/config-{$tmp}.xml";
if (is_file($bckfilename)) {
return $bckfilename;
} else {
return false;
}
}
/**
* remove old backups
*/