@@ -149,7 +149,6 @@ module.exports = {
149
149
blob . free ( ) ;
150
150
tree . free ( ) ;
151
151
} catch ( err ) {
152
- console . log ( 'err:' , err ) ;
153
152
ctx . response . status = err . statusCode || err . status || 500 ;
154
153
ctx . body = { message : err . message , ...err }
155
154
}
@@ -160,18 +159,17 @@ module.exports = {
160
159
const { reposPath } = ctx . state . conf ;
161
160
repo = repo . replace ( / .g i t $ / , '' ) ;
162
161
let transaction ;
163
-
164
162
try {
165
163
// 托管事务
166
164
transaction = await Models . sequelize . transaction ( ) ;
167
165
const namespaces = await Models . namespaces . findOne ( { where : { name : owner } , transaction } ) ;
168
166
if ( ! namespaces || ! namespaces . id ) ctx . throw ( 404 , 'Owner does not exist!' ) ;
169
167
const projects = await Models . projects . findOne ( { where : { name : repo , namespace_id : namespaces . id } , transaction } ) ;
170
168
if ( ! projects || ! projects . id ) ctx . throw ( 404 , 'Repo does not exist!' ) ;
171
- // await Models.projects.destroy({ where: { id: 1 }});
172
- await Models . projects . destroy ( { where : { namespace_id : namespaces . id , name : repo } , force : true , transaction } ) ;
173
169
// 删除用户创建仓库的记录
174
170
await Models . user_interacted_projects . destroy ( { where : { project_id : projects . id , creator_id : namespaces . owner_id } , transaction } ) ;
171
+ // 删除仓库信息
172
+ await Models . projects . destroy ( { where : { name : repo } , transaction } ) ;
175
173
// remove repo
176
174
await removeDir ( PATH . join ( reposPath , owner , `${ repo } .git` ) ) ;
177
175
// transaction commit 事务提交
@@ -206,11 +204,9 @@ module.exports = {
206
204
where : { id } ,
207
205
include : [ { model : Models . users , as : 'owner' , attributes : { exclude : [ 'password' ] } } ]
208
206
} ) ;
209
-
210
207
const { reposPath } = ctx . state . conf ;
211
208
const currentRepoPath = PATH . join ( reposPath , projects . namespace . name , `${ projects . name } .git` ) ;
212
209
const gitRepo = await Git . Repository . open ( currentRepoPath ) ;
213
-
214
210
// 空仓库返回 README.md 说明内容
215
211
let emptyRepoReadme = await readFile ( PATH . join ( __dirname , 'EmptyRepo.md' ) ) ;
216
212
if ( gitRepo . isEmpty ( ) === 1 ) {
0 commit comments