Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
		
							parent
							
								
									423c642fdb
								
							
						
					
					
						commit
						e55eaa8545
					
				
					 1 changed files with 15 additions and 1 deletions
				
			
		|  | @ -244,6 +244,8 @@ func MirrorUpdate() { | ||||||
| // SyncMirrors checks and syncs mirrors. | // SyncMirrors checks and syncs mirrors. | ||||||
| // TODO: sync more mirrors at same time. | // TODO: sync more mirrors at same time. | ||||||
| func SyncMirrors() { | func SyncMirrors() { | ||||||
|  | 	sess := x.NewSession() | ||||||
|  | 	defer sess.Close() | ||||||
| 	// Start listening on new sync requests. | 	// Start listening on new sync requests. | ||||||
| 	for repoID := range MirrorQueue.Queue() { | 	for repoID := range MirrorQueue.Queue() { | ||||||
| 		log.Trace("SyncMirrors [repo_id: %v]", repoID) | 		log.Trace("SyncMirrors [repo_id: %v]", repoID) | ||||||
|  | @ -260,10 +262,22 @@ func SyncMirrors() { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		m.ScheduleNextUpdate() | 		m.ScheduleNextUpdate() | ||||||
| 		if err = UpdateMirror(m); err != nil { | 		if err = updateMirror(sess, m); err != nil { | ||||||
| 			log.Error(4, "UpdateMirror [%s]: %v", repoID, err) | 			log.Error(4, "UpdateMirror [%s]: %v", repoID, err) | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		// Get latest commit date and update to current repository updated time | ||||||
|  | 		commitDate, err := git.GetLatestCommitTime(m.Repo.RepoPath()) | ||||||
|  | 		if err != nil { | ||||||
|  | 			log.Error(2, "GetLatestCommitDate [%s]: %v", m.RepoID, err) | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if _, err = sess.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil { | ||||||
|  | 			log.Error(2, "Update repository 'updated_unix' [%s]: %v", m.RepoID, err) | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bo-Yi Wu
						Bo-Yi Wu