mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
(config) prevent backup collisions (start using microtime)
This commit is contained in:
parent
11913af853
commit
ef787b91a2
@ -396,14 +396,17 @@ class Config extends Singleton
|
||||
public function backup()
|
||||
{
|
||||
$target_dir = dirname($this->config_file)."/backup/";
|
||||
$target_filename = "config-".time().".xml";
|
||||
$target_filename = "config-".microtime(true).".xml";
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
// create backup directory if it's missing
|
||||
mkdir($target_dir);
|
||||
}
|
||||
copy($this->config_file, $target_dir.$target_filename);
|
||||
|
||||
// The new target backup filename shouldn't exists, because of the use of microtime.
|
||||
// But if for some reason a script keeps calling this backup very often, it shouldn't crash.
|
||||
if (!file_exists($target_dir . $target_filename)) {
|
||||
copy($this->config_file, $target_dir . $target_filename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user