auto-rename and symlink-any can be turned off now

This commit is contained in:
lilydjwg 2013-08-23 22:10:08 +08:00
parent da2e89df66
commit 4070b63315
3 changed files with 17 additions and 4 deletions

View file

@ -28,6 +28,7 @@ TODO
- [high] adding and then removing it before adding complete will result
in not-in-database removing
- [middle] disable "any" architecture via config
- [middle] some attributes should be set on the EventHandler
- [low] fork to background
- [low] use one common command queue (now one each repo)
- [low] verify packages

View file

@ -27,10 +27,15 @@ path: /home/lilydjwg/tmpfs/test
#command-remove: repo-remove
# By enabling auto-rename, the server will automatically rename the package
# files according to .PKGINFO, and move them under the correct architecture
# files according to filenames, and move them under the correct architecture
# directory. Default is on.
#auto-rename: on
# By enabling symlink-any, the server will automatically symlink the package
# files of 'any' architecture to 'i686' and 'x86_64'
# Default is on.
#symlink-any: on
# Seconds before actually running the command. 10s by default.
#wait-time: 10
wait-time: 3

View file

@ -59,6 +59,8 @@ class RepoMan:
self._command_remove = config.get('command-remove', 'repo-remove')
self._wait_time = config.getint('wait-time', 10)
self._without_db = config.getboolean('without-db', False)
self._auto_rename = config.getboolean('auto-rename', True)
self._symlink_any = config.getboolean('symlink-any', True)
notification_type = config.get('notification-type', 'null')
if notification_type != 'null':
@ -235,6 +237,8 @@ class EventHandler(pyinotify.ProcessEvent):
wm.add_watch(d, pyinotify.ALL_EVENTS)
self.repomans[d] = RepoMan(config, d, self._ioloop)
self.name = self.repomans[d].name
self._auto_rename = self.repomans[d]._auto_rename
self._symlink_any = self.repomans[d]._symlink_any
self._initial_update(files)
@ -306,7 +310,7 @@ class EventHandler(pyinotify.ProcessEvent):
base, arch = os.path.split(d)
# rename if a packager has added to a wrong directory
if action == 'add' and act.arch != arch:
if self._auto_rename and action == 'add' and act.arch != arch:
newd = os.path.join(base, act.arch)
newpath = os.path.join(newd, file)
os.rename(path, newpath)
@ -316,8 +320,11 @@ class EventHandler(pyinotify.ProcessEvent):
arch = act.arch
d = newd
if arch == 'any':
for newarch in ('i686', 'x86_64'):
if self._symlink_any and act.arch == 'any':
for newarch in ('i686', 'x86_64', 'any'):
if newarch == arch:
# this file itself
continue
newd = os.path.join(base, newarch)
newpath = os.path.join(newd, file)
if action == 'add':