public bool Apply(WeatherObject weather) {
if (AcRootDirectory.Instance.Value == null) return false;
var source = Path.Combine(weather.Location, RelativeSource);
if (!File.Exists(source)) return false;
var destination = Path.Combine(AcRootDirectory.Instance.RequireValue, RelativeDestination);
var backup = Path.Combine(AcRootDirectory.Instance.RequireValue, RelativeBackup);
if (File.Exists(destination)) {
if (File.Exists(backup)) {
File.Move(backup, FileUtils.EnsureUnique(backup));
}
Logging.Debug($"{destination} → {backup}");
File.Move(destination, backup);
}
try {
Logging.Debug($"{source} → {destination}");
FileUtils.Hardlink(source, destination);
} catch (Exception e) {
// this exception should be catched here so original clouds folder still
// will be restored even when copying a new one has been failed
NonfatalError.Notify("Can’t replace weather-specific files", e);
}
return true;
}