mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
add owner, mtime and pkgver to info database
This commit is contained in:
parent
81cbd9cbb1
commit
36206900f3
1 changed files with 16 additions and 2 deletions
18
archreposrv
18
archreposrv
|
@ -4,6 +4,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import pwd
|
||||||
import configparser
|
import configparser
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import queue
|
import queue
|
||||||
|
@ -140,6 +141,9 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
(filename text unique,
|
(filename text unique,
|
||||||
pkgname text,
|
pkgname text,
|
||||||
pkgarch text,
|
pkgarch text,
|
||||||
|
pkgver text,
|
||||||
|
owner text,
|
||||||
|
mtime int,
|
||||||
state int)''')
|
state int)''')
|
||||||
|
|
||||||
dirs = [os.path.join(base, x) for x in ('any', 'i686', 'x86_64')]
|
dirs = [os.path.join(base, x) for x in ('any', 'i686', 'x86_64')]
|
||||||
|
@ -237,9 +241,19 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
if act.action == 'add':
|
if act.action == 'add':
|
||||||
self._db.execute('update pkginfo set state = 0 where pkgname = ? and pkgarch = ?', (act.name, act.arch))
|
self._db.execute('update pkginfo set state = 0 where pkgname = ? and pkgarch = ?', (act.name, act.arch))
|
||||||
def callback():
|
def callback():
|
||||||
|
stat = os.stat(act.path)
|
||||||
|
mtime = int(stat.st_mtime)
|
||||||
|
try:
|
||||||
|
owner = pwd.getpwuid(stat.st_uid).pw_name
|
||||||
|
except KeyError:
|
||||||
|
owner = 'uid_%d' % stat.st_uid
|
||||||
|
|
||||||
self._db.execute(
|
self._db.execute(
|
||||||
'insert or replace into pkginfo (filename, pkgname, pkgarch, state) values (?, ?, ?, ?)',
|
'''insert or replace into pkginfo
|
||||||
(act.path, act.name, act.arch, 1))
|
(filename, pkgname, pkgarch, pkgver, state, owner, mtime) values
|
||||||
|
(?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
(act.path, act.name, act.arch, act.fullversion, 1, owner, mtime))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
res = self._db.execute('select state from pkginfo where filename = ? and state = 1 limit 1', (act.path,))
|
res = self._db.execute('select state from pkginfo where filename = ? and state = 1 limit 1', (act.path,))
|
||||||
if tuple(res) == ():
|
if tuple(res) == ():
|
||||||
|
|
Loading…
Add table
Reference in a new issue