I want to be able to touch files, updating their modtime timestamps. My particular application requires that there be an option to truncate the file or not upon touching it. To truncate touch it, I'm just opening it using the DELETE flag and to not truncate, I'm opening with the UPDATE flag. The former method results in the timestamp updating while the latter doesnt and attached is a simple script that demonstrates this. Is there a way to update the modtime without modifying the file, to "touch" it as its called?

from XRootD import client
from XRootD.client.flags import DirListFlags, OpenFlags, MkDirFlags, QueryCode
import time

local_server = 'YOUR LOCAL SERVER'
path = '/tmp/eggs'

with client.File() as f:
status, _ = f.open(local_server+"/"+path, OpenFlags.DELETE)
if not status.ok:
raise OSError(f"Something went wrong: {status.message}")
status, _ = f.write('green\neggs\nand\nham\n')
if not status.ok:
raise OSError(f"Something went wrong: {status.message}")

myclient = client.FileSystem(local_server)

status, deets = myclient.stat(path)
if not status.ok:
raise OSError(f"Something went wrong: {status.message}")
t1 = deets.modtime
time.sleep(1)
print(t1)

with client.File() as f:
f.open(local_server+"/"+path, OpenFlags.UPDATE)

status, deets = myclient.stat(path)
t2 = deets.modtime
time.sleep(1)
print(t2)

with client.File() as f:
f.open(local_server+"/"+path, OpenFlags.DELETE)

status, deets = myclient.stat(path)
t3 = deets.modtime
time.sleep(1)
print(t3)

print(t1<t2)
print(t2<t3)
assert t1 < t2 and t2 < t3


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <xrootd/xrootd/issues/1737@github.com>

[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/xrootd/xrootd/issues/1737", "url": "https://github.com/xrootd/xrootd/issues/1737", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1