Disallow link hints when document was rotated
[llpp.git] / misc / gc.py
blob37349c4f1f26d7c4cf5f4a42c44eed5a304dfb56
1 #!/usr/bin/env python
2 import os, sys, subprocess
4 fields = sys.stdin.read ().split ('\x00')
6 while len (fields) > 1:
7 opath, atime = fields[0:2]
8 fields = fields[2:]
9 if not os.path.exists (opath):
10 try:
11 npath = subprocess.check_output (
12 "locate -b -l 1 -e '/%s$'" % opath,
13 shell = False
15 except:
16 sys.stderr.write ("removing " + opath + "\n")
17 npath = ""
18 npath = npath[:-1]
19 sys.stdout.write (opath + "\000" + npath + "\000")
20 elif os.path.isdir (opath):
21 sys.stdout.write (opath + "\000\000")
23 sys.stderr.write (sys.argv[0] + " done\n")