Skip to content

Commit 5668c2d

Browse files
committed
Add WEKO patch to delay file content task to avoid ES version conflict
1 parent 9e0c147 commit 5668c2d

4 files changed

Lines changed: 310 additions & 16 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/modules/weko-deposit/weko_deposit/api.py b/modules/weko-deposit/weko_deposit/api.py
2+
index XXXXXXX..XXXXXXX 100644
3+
--- a/modules/weko-deposit/weko_deposit/api.py
4+
+++ b/modules/weko-deposit/weko_deposit/api.py
5+
@@ -1025,7 +1025,8 @@ class WekoDeposit(Deposit):
6+
self.revision_id)
7+
# Upload pdf file content to Elasticsearch
8+
from .tasks import extract_pdf_and_update_file_contents
9+
- extract_pdf_and_update_file_contents.apply_async((reading_targets, str(self.pid.object_uuid)))
10+
+ # Add countdown to avoid version conflict with web process
11+
+ extract_pdf_and_update_file_contents.apply_async((reading_targets, str(self.pid.object_uuid)), countdown=10)
12+
except TransportError as err:
13+
if self.jrc.get('content'):
14+
for content in self.jrc['content']:

.github/scripts/setup_weko.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ case "$COMMAND" in
4747
patch -d "${WEKO_ROOT}" -p1 < "${SCRIPT_DIR}/../patches/weko-oauth2-insecure-transport.patch"
4848
# Apply patch to fix chardet TypeError on ZIP filename handling
4949
patch -d "${WEKO_ROOT}" -p1 < "${SCRIPT_DIR}/../patches/weko-chardet-fix.patch"
50+
# Apply patch to delay file content extraction task to avoid ES version conflict
51+
patch -d "${WEKO_ROOT}" -p1 < "${SCRIPT_DIR}/../patches/weko-delay-file-content-task.patch"
5052
# Generate self-signed certificate for WEKO nginx with SAN for IP address
5153
mkdir -p "${WEKO_ROOT}/nginx/keys"
5254
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
@@ -89,6 +91,44 @@ db.session.commit()
8991
print('Updated mapping 30002')
9092
"
9193

94+
# Grant contributor access to Sample Index
95+
echo "=== Granting Contributor Access to Sample Index ==="
96+
docker compose -f "${compose_file}" exec -T web invenio shell -c '
97+
from weko_index_tree.models import Index
98+
from invenio_db import db
99+
index = Index.query.filter_by(index_name_english="Sample Index").first()
100+
if index:
101+
print(f"Before: contribute_role={index.contribute_role}, browsing_role={index.browsing_role}")
102+
index.contribute_role = "1,2,3,4,-98,-99"
103+
index.browsing_role = "1,2,3,4,-98,-99"
104+
index.public_state = True
105+
db.session.commit()
106+
print(f"After: contribute_role={index.contribute_role}, browsing_role={index.browsing_role}")
107+
else:
108+
print("Sample Index not found")
109+
exit(1)
110+
'
111+
112+
# Grant index-tree-access permission to Contributor role
113+
echo "=== Granting index-tree-access to Contributor ==="
114+
docker compose -f "${compose_file}" exec -T web invenio shell -c '
115+
from invenio_access.models import ActionRoles, Role
116+
from invenio_db import db
117+
role = Role.query.filter_by(name="Contributor").first()
118+
if role:
119+
existing = ActionRoles.query.filter_by(action="index-tree-access", role_id=role.id).first()
120+
if existing:
121+
print(f"index-tree-access already granted to Contributor (role_id={role.id})")
122+
else:
123+
ar = ActionRoles(action="index-tree-access", role_id=role.id)
124+
db.session.add(ar)
125+
db.session.commit()
126+
print(f"Granted index-tree-access to Contributor (role_id={role.id})")
127+
else:
128+
print("Contributor role not found")
129+
exit(1)
130+
'
131+
92132
# Validate SWORD mapping 30002
93133
echo "=== SWORD Mapping Validation (30002) ==="
94134
validation_result=$(docker compose -f "${compose_file}" exec -T web invenio shell -c '

テスト手順-WEKOアドオン-アドオン追加.ipynb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,6 +4891,34 @@
48914891
"await run_pw(_step)\n"
48924892
]
48934893
},
4894+
{
4895+
"cell_type": "markdown",
4896+
"id": "wp8nockzkos",
4897+
"source": "## ドロップダウンから「Log out」をクリックする\n\nログアウトされ、WEKO3のトップ画面が表示されること",
4898+
"metadata": {}
4899+
},
4900+
{
4901+
"cell_type": "code",
4902+
"id": "nqhy9erzu6q",
4903+
"source": "async def _step(page):\n await page.locator('//div[contains(@class, \"navbar-form\")]//button[contains(@class, \"dropdown-toggle\")]').click()\n await expect(page.locator('//a[@href = \"/logout/\"]')).to_be_visible(timeout=transition_timeout)\n await page.locator('//a[@href = \"/logout/\"]').click()\n await expect(page.locator('//a[contains(@class, \"login-button\")]')).to_be_visible(timeout=transition_timeout)\n\nawait run_pw(_step)",
4904+
"metadata": {},
4905+
"execution_count": null,
4906+
"outputs": []
4907+
},
4908+
{
4909+
"cell_type": "markdown",
4910+
"id": "087b4z3vc41",
4911+
"source": "## 「ログイン」をクリックし、WEKOユーザーアカウントでログインする\n\nWEKO3のアイテム画面が表示されること",
4912+
"metadata": {}
4913+
},
4914+
{
4915+
"cell_type": "code",
4916+
"id": "4iuntqhmvp8",
4917+
"source": "async def _step(page):\n await page.locator('//a[contains(@class, \"login-button\")]').click()\n await expect(page.locator('//input[@name = \"email\"]')).to_be_visible(timeout=transition_timeout)\n await page.locator('//input[@name = \"email\"]').fill(weko_user_email)\n await page.locator('//input[@name = \"password\"]').fill(weko_user_password)\n await page.locator('//button[@type = \"submit\"]').click()\n await expect(page.locator('//a[@href = \"/account/settings/profile/\" and .//i[@class=\"fa fa-user\"]]')).to_be_visible(timeout=transition_timeout)\n\nawait run_pw(_step)",
4918+
"metadata": {},
4919+
"execution_count": null,
4920+
"outputs": []
4921+
},
48944922
{
48954923
"cell_type": "markdown",
48964924
"id": "39b71328-855f-430f-a4d8-da0756137933",

0 commit comments

Comments
 (0)