2014-05-03 12:34:36 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class Store::Provider::DB < ApplicationModel
|
|
|
|
self.table_name = 'store_provider_dbs'
|
|
|
|
|
2014-05-03 14:52:37 +00:00
|
|
|
def self.add(data, sha)
|
2014-05-03 12:34:36 +00:00
|
|
|
Store::Provider::DB.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
data: data,
|
|
|
|
sha: sha,
|
2014-05-03 12:34:36 +00:00
|
|
|
)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2014-05-03 14:52:37 +00:00
|
|
|
def self.get(sha)
|
2015-04-27 13:42:53 +00:00
|
|
|
file = Store::Provider::DB.where( sha: sha ).first
|
2014-05-03 12:34:36 +00:00
|
|
|
return if !file
|
|
|
|
file.data
|
|
|
|
end
|
|
|
|
|
2014-05-03 14:52:37 +00:00
|
|
|
def self.delete(sha)
|
2015-04-27 13:42:53 +00:00
|
|
|
Store::Provider::DB.where( sha: sha ).destroy_all
|
2014-05-03 12:34:36 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|