-
-class Public(DBWorker):
- """Paths can be marked as public."""
-
- def __init__(self, **params):
- DBWorker.__init__(self, **params)
- execute = self.execute
-
- execute(""" create table if not exists public
- ( public_id integer primary key autoincrement,
- path text not null,
- active boolean not null default 1 ) """)
- execute(""" create unique index if not exists idx_public_path
- on public(path) """)
-
- def public_set(self, path):
- q = "insert or ignore into public (path) values (?)"
- self.execute(q, (path,))
- q = "update public set active = 1 where path = ?"
- self.execute(q, (path,))
-
- def public_unset(self, path):
- q = "update public set active = 0 where path = ?"
- self.execute(q, (path,))
-
- def public_unset_bulk(self, paths):
- placeholders = ','.join('?' for path in paths)
- q = "update public set active = 0 where path in (%s)" % placeholders
- self.execute(q, paths)
-
- def public_get(self, path):
- q = "select public_id from public where path = ? and active = 1"
- self.execute(q, (path,))
- row = self.fetchone()
- if row:
- return row[0]
- return None
-
- def public_list(self, prefix):
- q = "select path, public_id from public where path like ? escape '\\' and active = 1"
- self.execute(q, (self.escape_like(prefix) + '%',))
- return self.fetchall()
-
- def public_path(self, public):
- q = "select path from public where public_id = ? and active = 1"
- self.execute(q, (public,))
- row = self.fetchone()
- if row:
- return row[0]
- return None
-
-class QuotaholderSync(DBWorker):
- """QuotaholderSync are entries for syncing with quota holder.