forked from vieter-v/vieter
				
			
							parent
							
								
									e13252d368
								
							
						
					
					
						commit
						398758a727
					
				|  | @ -17,7 +17,7 @@ pub: | ||||||
| 	download_dir string | 	download_dir string | ||||||
| 	api_key      string | 	api_key      string | ||||||
| 	repo_dir     string | 	repo_dir     string | ||||||
| 	repos_file string | 	repos_file   string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub struct BuildConfig { | pub struct BuildConfig { | ||||||
|  |  | ||||||
|  | @ -20,13 +20,14 @@ fn read_repos(path string) ?[]GitRepo { | ||||||
| 			f.close() | 			f.close() | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		f.write_string('{}') ? | 		f.write_string('[]') ? | ||||||
| 
 | 
 | ||||||
| 		return [] | 		return [] | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	content := os.read_file(path) ? | 	content := os.read_file(path) ? | ||||||
| 	return json.decode([]GitRepo, content) | 	res := json.decode([]GitRepo, content) ? | ||||||
|  | 	return res | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn write_repos(path string, repos []GitRepo) ? { | fn write_repos(path string, repos []GitRepo) ? { | ||||||
|  | @ -36,7 +37,6 @@ fn write_repos(path string, repos []GitRepo) ? { | ||||||
| 		f.close() | 		f.close() | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	dump(repos) |  | ||||||
| 	value := json.encode(repos) | 	value := json.encode(repos) | ||||||
| 	f.write_string(value) ? | 	f.write_string(value) ? | ||||||
| } | } | ||||||
|  | @ -91,9 +91,7 @@ pub fn (mut app App) post_repo() web.Result { | ||||||
| 	repos << new_repo | 	repos << new_repo | ||||||
| 
 | 
 | ||||||
| 	lock app.git_mutex { | 	lock app.git_mutex { | ||||||
| 		write_repos(app.conf.repos_file, repos) or { | 		write_repos(app.conf.repos_file, repos) or { return app.server_error(500) } | ||||||
| 			return app.server_error(500) |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return app.ok('Repo added successfully.') | 	return app.ok('Repo added successfully.') | ||||||
|  |  | ||||||
|  | @ -88,4 +88,3 @@ pub fn pretty_bytes(bytes int) string { | ||||||
| 
 | 
 | ||||||
| 	return '${n:.2}${util.prefixes[i]}' | 	return '${n:.2}${util.prefixes[i]}' | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue