meskyanichi/backup — Issue #270: Logger tries to get file stats for not yet existing log file on initial backup
Author: kostia
Created: 2012-01-31 16:40:29+00:00
State: open

The logger tries to truncate not yet existing log file in `backup/log/backup.log`, which results in an exception "No such file", when the backup has been initiated for the first time.

Here is the appropriate code snippet:

```ruby
# backup/logger.rb
def truncate!(max_bytes = 500_000)
log_file = File.join(Config.log_path, 'backup.log')
if File.stat(log_file).size > max_bytes # This line fails for there is no log file yet!

# backup/cli/utility.rb

def perform
#...
Logger.truncate! # Boom!
```

To make it right `#truncate!`should look for the log file and immediately return if it doesn't exist.

Backup version 3.0.21