##// END OF EJS Templates
Prefix gist storage with rc, and store some metadata info into...
marcink -
r3841:979edf6a beta
parent child Browse files
Show More
@@ -22,7 +22,7 b''
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25 from __future__ import with_statement
26 import os
26 import os
27 import time
27 import time
28 import logging
28 import logging
@@ -32,6 +32,7 b' import shutil'
32 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
33 from rhodecode.lib.utils2 import safe_unicode, unique_id, safe_int, \
33 from rhodecode.lib.utils2 import safe_unicode, unique_id, safe_int, \
34 time_to_datetime, safe_str, AttributeDict
34 time_to_datetime, safe_str, AttributeDict
35 from rhodecode.lib.compat import json
35 from rhodecode.lib import helpers as h
36 from rhodecode.lib import helpers as h
36 from rhodecode.model import BaseModel
37 from rhodecode.model import BaseModel
37 from rhodecode.model.db import Gist
38 from rhodecode.model.db import Gist
@@ -41,7 +42,8 b' from rhodecode.lib.vcs import get_repo'
41
42
42 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
43
44
44 GIST_STORE_LOC = '.gist_store'
45 GIST_STORE_LOC = '.rc_gist_store'
46 GIST_METADATA_FILE = '.rc_gist_metadata'
45
47
46
48
47 class GistModel(BaseModel):
49 class GistModel(BaseModel):
@@ -143,7 +145,17 b' class GistModel(BaseModel):'
143 nodes=processed_mapping,
145 nodes=processed_mapping,
144 trigger_push_hook=False
146 trigger_push_hook=False
145 )
147 )
146
148 # store metadata inside the gist, this can be later used for imports
149 # or gist identification
150 metadata = {
151 'gist_db_id': gist.gist_id,
152 'gist_access_id': gist.gist_access_id,
153 'gist_owner_id': owner.user_id,
154 'gist_type': gist.gist_type,
155 'gist_exipres': gist.gist_expires
156 }
157 with open(os.path.join(repo.path, '.hg', GIST_METADATA_FILE), 'wb') as f:
158 f.write(json.dumps(metadata))
147 return gist
159 return gist
148
160
149 def delete(self, gist, fs_remove=True):
161 def delete(self, gist, fs_remove=True):
General Comments 0
You need to be logged in to leave comments. Login now