mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
support symlinks
This commit is contained in:
parent
0a0fce77bc
commit
1f206e12d4
2 changed files with 17 additions and 4 deletions
|
@ -11,6 +11,10 @@ DEPENDENCIES
|
||||||
* pyinotify, tested with 0.9.4
|
* pyinotify, tested with 0.9.4
|
||||||
* winterpy (add `pylib` to `$PYTHONPATH`)
|
* winterpy (add `pylib` to `$PYTHONPATH`)
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
====
|
||||||
|
* relative symlinks may be broken when moving to the right architecture directory
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
* [high] adding and then removing it before adding complete will result in not-in-database removing
|
* [high] adding and then removing it before adding complete will result in not-in-database removing
|
||||||
|
@ -18,5 +22,4 @@ TODO
|
||||||
* [middle] `setup.py` support
|
* [middle] `setup.py` support
|
||||||
* [middle] disable "any" architecture via config
|
* [middle] disable "any" architecture via config
|
||||||
* [low] use one common command queue (now one each repo)
|
* [low] use one common command queue (now one each repo)
|
||||||
* [low] support symlinking packages here
|
|
||||||
* [low] verify packages
|
* [low] verify packages
|
||||||
|
|
16
repomon.py
16
repomon.py
|
@ -202,6 +202,7 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
def my_init(self, config, wm, ioloop=None):
|
def my_init(self, config, wm, ioloop=None):
|
||||||
self.moved_away = {}
|
self.moved_away = {}
|
||||||
self.repomans = {}
|
self.repomans = {}
|
||||||
|
self.our_links = set()
|
||||||
self._ioloop = ioloop or IOLoop.instance()
|
self._ioloop = ioloop or IOLoop.instance()
|
||||||
|
|
||||||
base = config.get('path')
|
base = config.get('path')
|
||||||
|
@ -261,6 +262,16 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
# symlinks haven't been added
|
# symlinks haven't been added
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def process_IN_CREATE(self, event):
|
||||||
|
file = event.pathname
|
||||||
|
if os.path.islink(file):
|
||||||
|
if file in self.our_links:
|
||||||
|
self.our_links.remove(file)
|
||||||
|
else:
|
||||||
|
logger.debug('Symlinked: %s', file)
|
||||||
|
self.dispatch(file, 'add')
|
||||||
|
self.files.add(file)
|
||||||
|
|
||||||
def movedOut(self, event):
|
def movedOut(self, event):
|
||||||
logger.debug('Moved away: %s', event.pathname)
|
logger.debug('Moved away: %s', event.pathname)
|
||||||
self.dispatch(event.pathname, 'remove')
|
self.dispatch(event.pathname, 'remove')
|
||||||
|
@ -295,9 +306,7 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
base, arch = os.path.split(d)
|
base, arch = os.path.split(d)
|
||||||
|
|
||||||
# rename if a packager has added to a wrong directory
|
# rename if a packager has added to a wrong directory
|
||||||
# but not for a link that has arch=any, as that's what we created
|
if action == 'add' and act.arch != arch:
|
||||||
if action == 'add' and act.arch != arch and not \
|
|
||||||
(os.path.islink(path) and act.arch == 'any'):
|
|
||||||
newd = os.path.join(base, act.arch)
|
newd = os.path.join(base, act.arch)
|
||||||
newpath = os.path.join(newd, file)
|
newpath = os.path.join(newd, file)
|
||||||
os.rename(path, newpath)
|
os.rename(path, newpath)
|
||||||
|
@ -313,6 +322,7 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
newpath = os.path.join(newd, file)
|
newpath = os.path.join(newd, file)
|
||||||
if action == 'add':
|
if action == 'add':
|
||||||
try:
|
try:
|
||||||
|
self.our_links.add(newpath)
|
||||||
os.symlink(os.path.join('..', arch, file), newpath)
|
os.symlink(os.path.join('..', arch, file), newpath)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue