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

kconfig: kconfiglib.py: Backup files only #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions kconfiglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,7 @@ def write_config(self, filename=None, header=None, save_old=True,
written.

Errors are silently ignored if <filename>.old cannot be written (e.g.
due to being a directory, or <filename> being something like
/dev/null).
due to permissions errors).

verbose (default: None):
Limited backwards compatibility to prevent crashes. A warning is
Expand Down Expand Up @@ -6392,6 +6391,12 @@ def _touch_dep_file(path, sym_name):
def _save_old(path):
# See write_config()

if not os.path.isfile(path):
# Backup only files (and symlinks to files). Simplest alternative
# to avoid e.g. (potentially successful attempt to) rename /dev/null
# (and to keep fifos).
return

def copy(src, dst):
# Import as needed, to save some startup time
import shutil
Expand All @@ -6416,8 +6421,7 @@ def copy(src, dst):
except Exception:
# Ignore errors from 'path' missing as well as other errors.
# <filename>.old file is usually more of a nice-to-have, and not worth
# erroring out over e.g. if <filename>.old happens to be a directory or
# <filename> is something like /dev/null.
# erroring out over e.g. if <filename>.old happens to be a directory.
pass


Expand Down