!4 Add exist_ok=True in os.makedirs to avoid failure due to race condition

Merge pull request !4 from 李振华/master
This commit is contained in:
openeuler-ci-bot 2020-06-24 09:05:05 +08:00 committed by Gitee
commit 76c7ca8478
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From 7034f592314a79903c8ce5958de4deba2c13ae22 Mon Sep 17 00:00:00 2001
From: Mike FABIAN <mfabian@redhat.com>
Date: Mon, 6 Jan 2020 19:09:56 +0100
Subject: [PATCH] Add exist_ok=True in os.makedirs(path, exist_ok=True) to
avoid failure due to race condition
Resolves: rhbz#1786652 (https://bugzilla.redhat.com/show_bug.cgi?id=1786652)
[abrt] ibus-table: makedirs(): os.py:221:makedirs:FileExistsError: [Errno 17] File exists: '/home/username/.local/share/ibus-table'
---
engine/ibus_table_location.py | 4 ++--
engine/tabsqlitedb.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/engine/ibus_table_location.py b/engine/ibus_table_location.py
index dee718d..036b372 100644
--- a/engine/ibus_table_location.py
+++ b/engine/ibus_table_location.py
@@ -73,7 +73,7 @@ def _init():
IBUS_TABLE_LOCATION['data_home'] = os.path.join(
IBUS_TABLE_LOCATION['data_home'], 'ibus-table')
if not os.access(IBUS_TABLE_LOCATION['data_home'], os.F_OK):
- os.makedirs(IBUS_TABLE_LOCATION['data_home'])
+ os.makedirs(IBUS_TABLE_LOCATION['data_home'], exist_ok=True)
# $XDG_CACHE_HOME defines the base directory relative to which user
# specific non-essential data files should be stored. If
@@ -89,7 +89,7 @@ def _init():
IBUS_TABLE_LOCATION['cache_home'] = os.path.join(
IBUS_TABLE_LOCATION['cache_home'], 'ibus-table')
if not os.access(IBUS_TABLE_LOCATION['cache_home'], os.F_OK):
- os.makedirs(IBUS_TABLE_LOCATION['cache_home'])
+ os.makedirs(IBUS_TABLE_LOCATION['cache_home'], exist_ok=True)
class __ModuleInitializer:
def __init__(self):
diff --git a/engine/tabsqlitedb.py b/engine/tabsqlitedb.py
index d9a8de2..60038a7 100644
--- a/engine/tabsqlitedb.py
+++ b/engine/tabsqlitedb.py
@@ -298,7 +298,7 @@ def __init__(
shutil.rmtree(old_tables_path)
os.symlink(tables_path, old_tables_path)
else:
- os.makedirs(tables_path)
+ os.makedirs(tables_path, exist_ok=True)
user_db = path.join(tables_path, user_db)
if not path.exists(user_db):
sys.stderr.write(

View File

@ -1,10 +1,11 @@
Name: ibus-table
Version: 1.9.21
Release: 4
Release: 5
Summary: Table engine for Intelligent Input Bus (IBus)
License: LGPLv2+
URL: http://code.google.com/p/ibus/
Source0: http://github.com/kaio/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz
Patch0000: Add-exist_ok-True-in-os-makedirs-to-avoid-failure-due-to-race-condition.patch
BuildArch: noarch
BuildRequires: ibus-devel > 1.3.0, python3-devel, libappstream-glib
@ -86,6 +87,9 @@ make check || cat ./tests/test-suite.log
%{_mandir}/man*/*
%changelog
* Tue Jun 23 2020 lizhenhua <lizhenhua21@huawei.com> - 1.9.21-5
- Add exist_ok=True in os.makedirs to avoid failure due to race condition
* Tue Apr 7 2020 fuanan <fuanan3@huawei.com> - 1.9.21-4
- Replace Source0