Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not found .json (settings) at first run #68

Open
MicheleAnnunziata opened this issue Mar 16, 2020 · 2 comments · May be fixed by #69
Open

Not found .json (settings) at first run #68

MicheleAnnunziata opened this issue Mar 16, 2020 · 2 comments · May be fixed by #69
Assignees

Comments

@MicheleAnnunziata
Copy link

The first time incrementalbackup is run there is an exception caused by not reading the json file (which does not exist) in the destination folder. I made the example with Tar. I found the error in the getSetting method of the Tar class

Screenshot (17)

It always ($settings_file) true and at the first time _destination->read goes in exception because the .json file will not be found

<?php
/**
     * Get the backup settings, # of backups and backup unix timestamps.
     *
     * @return mixed|object
     */
    public function getSettings()
    {
        //$settings_file = $this->_destination->getPath() . DIRECTORY_SEPARATOR . $this->getSettingsFile();
 $settings_file = $this->_destination->read(DIRECTORY_SEPARATOR . $this->getSettingsFile());
        if ($settings_file) {
            return json_decode($settings_file);
        } // first time to backup.
        else {
            return (object)array(
                "number" => 0,
                "backups" => array()
            );
        }
    }
@iobotis iobotis self-assigned this Mar 18, 2020
@MicheleAnnunziata
Copy link
Author

If i can suggest, i made the following change. Thank's for you job

/**
     * Get the backup settings, # of backups and backup unix timestamps.
     *
     * @return mixed|object
     */
    public function getSettings()
    {
        $settings_file = $this->_destination->getPath() . DIRECTORY_SEPARATOR . $this->getSettingsFile();
        //$settings_file = $this->_destination->read(DIRECTORY_SEPARATOR . $this->getSettingsFile());
        if (is_file($settings_file)) {
            $settings_file = $this->_destination->read(DIRECTORY_SEPARATOR . $this->getSettingsFile());
            return json_decode($settings_file);
        } // first time to backup.
        else {
            return (object)array(
                "number" => 0,
                "backups" => array()
            );
        }
    }

@iobotis
Copy link
Owner

iobotis commented Mar 26, 2020

Hi,

There is a solution about this. Since I am trying to support both local and ftp destinations for the backup-ed files, I cannot use "is_file".

I will test the solution and see if this solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants