Merge lp:~gary-lasker/software-center/fix-makedirs-race-crashes into lp:software-center
Status: | Merged |
---|---|
Merged at revision: | 3006 |
Proposed branch: | lp:~gary-lasker/software-center/fix-makedirs-race-crashes |
Merge into: | lp:software-center |
Diff against target: |
174 lines (+82/-27) 4 files modified
softwarecenter/config.py (+2/-2) softwarecenter/log.py (+3/-3) softwarecenter/utils.py (+42/-22) test/test_logging.py (+35/-0) |
To merge this branch: | bzr merge lp:~gary-lasker/software-center/fix-makedirs-race-crashes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
software-store-developers | Pending | ||
Review via email: mp+105389@code.launchpad.net |
Description of the change
This branch fixes one of the most common software-center crashes as reported at errors.ubuntu.com, bug 743003, as well as bug 621182. These crashes appear to occur in new installs of Ubuntu, and are the result of a race between different processes creating the cache directory (for bug 743003) and the config directory (for bug 621182). The crash occurs because os.makedirs will throw an OSError if it is called and the directory is found to already exist. The fix for both of these use a new method in utils called safe_makedirs.
I also added a new unit test, test_logging.py, as suggested in comment #3 of bug 743003. This unit test checks the case where the cache directory is found to be not writable, and so is moved aside and a new cache directory created. I'm not sure if the code in log.py itself needs a change as it seems to work fine. It has been modified to use the new safe_makedirs method in any case.
Thanks for your review!
Thanks for the branch, it looks good, but there is a issue with the test.
I noticed that you use "os.chmod( cache_dir, 600)" here. As this is decimal 600 (and not octal) its confusing for me to read and will result in a odd permission on disk (see my comment for https:/ /code.launchpad .net/~gary- lasker/ software- center/ fix-shutdown- crash-lp996333/ +merge/ 105027). Please use either 0400 or stat.S_IRUSR.
It would be nice if safe_makedirs() would get a individual test in test_utils.py (even though its pretty trivial).