2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2014-05-03 12:34:36 +00:00
|
|
|
|
2015-04-27 21:44:41 +00:00
|
|
|
class Store
|
2015-04-27 22:02:11 +00:00
|
|
|
module Provider
|
2015-04-27 21:44:41 +00:00
|
|
|
class DB < ApplicationModel
|
|
|
|
self.table_name = 'store_provider_dbs'
|
2014-05-03 12:34:36 +00:00
|
|
|
|
2015-04-27 21:44:41 +00:00
|
|
|
def self.add(data, sha)
|
|
|
|
Store::Provider::DB.create(
|
|
|
|
data: data,
|
2018-12-19 17:31:51 +00:00
|
|
|
sha: sha,
|
2015-04-27 21:44:41 +00:00
|
|
|
)
|
|
|
|
true
|
|
|
|
end
|
2014-05-03 12:34:36 +00:00
|
|
|
|
2015-04-27 21:44:41 +00:00
|
|
|
def self.get(sha)
|
2016-02-02 12:50:49 +00:00
|
|
|
file = Store::Provider::DB.find_by(sha: sha)
|
2015-04-27 21:44:41 +00:00
|
|
|
return if !file
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2015-04-27 21:44:41 +00:00
|
|
|
file.data
|
|
|
|
end
|
2014-05-03 12:34:36 +00:00
|
|
|
|
2015-04-27 21:44:41 +00:00
|
|
|
def self.delete(sha)
|
2016-02-02 12:50:49 +00:00
|
|
|
Store::Provider::DB.where(sha: sha).destroy_all
|
2015-04-27 21:44:41 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2014-05-03 12:34:36 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|