[PATCH 2/4] Replace hashsplit.open_noatime with os.open

0 views
Skip to first unread message

Rob Browning

unread,
Mar 6, 2026, 6:13:47 PM (8 days ago) Mar 6
to bup-...@googlegroups.com
In the one place we called open_noatime, just use os.open directly
since python can handle it all now. Though the C open_noatime
is still used by other C code.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/cmd/save.py | 5 ++++-
lib/bup/hashsplit.py | 14 +-------------
2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/lib/bup/cmd/save.py b/lib/bup/cmd/save.py
index 7d00334b..f8d91207 100644
--- a/lib/bup/cmd/save.py
+++ b/lib/bup/cmd/save.py
@@ -1,6 +1,7 @@

from binascii import hexlify
from errno import ENOENT
+from os import O_NOATIME, O_NOFOLLOW, O_RDONLY
import math, os, stat, sys, time

from bup import hashsplit, options, index, client, metadata
@@ -384,7 +385,9 @@ def save_tree(opt, reader, hlink_db, msr, repo, split_cfg):
meta.size += len(data)
return repo.write_data(data)
before_saving_regular_file(ent.name)
- with hashsplit.open_noatime(ent.name) as f:
+
+ with open(os.open(ent.name, flags=O_RDONLY | O_NOFOLLOW | O_NOATIME),
+ 'rb', buffering=1024 * 1024) as f:
mode, id = \
split_to_blob_or_tree(write_data, repo.write_tree,
hashsplit.from_config([f], split_cfg))
diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py
index 15e12f0a..cd7465ff 100644
--- a/lib/bup/hashsplit.py
+++ b/lib/bup/hashsplit.py
@@ -1,5 +1,5 @@

-import math, os, re
+import math, re

from bup import _helpers
from bup.config import ConfigError
@@ -123,15 +123,3 @@ def split_to_blob_or_tree(makeblob, maketree, splitter):
return (GIT_MODE_FILE, makeblob(b''))
else:
return (GIT_MODE_TREE, maketree(shalist))
-
-
-def open_noatime(name):
- fd = _helpers.open_noatime(name)
- try:
- return os.fdopen(fd, 'rb', 1024*1024)
- except:
- try:
- os.close(fd)
- except:
- pass
- raise
--
2.47.3

Reply all
Reply to author
Forward
0 new messages