mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Add migrate repo archiver and packages storage support on command line (#20757)
* Add migrate repo archiver and packages storage support on command line * Fix typo * Use stdCtx * Use packageblob and fix command description * Add migrate packages unit tests * Fix comment year * Fix the migrate storage command line description * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Fix test Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		@@ -27,21 +27,21 @@ func NewContentStore() *ContentStore {
 | 
			
		||||
 | 
			
		||||
// Get gets a package blob
 | 
			
		||||
func (s *ContentStore) Get(key BlobHash256Key) (storage.Object, error) {
 | 
			
		||||
	return s.store.Open(keyToRelativePath(key))
 | 
			
		||||
	return s.store.Open(KeyToRelativePath(key))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Save stores a package blob
 | 
			
		||||
func (s *ContentStore) Save(key BlobHash256Key, r io.Reader, size int64) error {
 | 
			
		||||
	_, err := s.store.Save(keyToRelativePath(key), r, size)
 | 
			
		||||
	_, err := s.store.Save(KeyToRelativePath(key), r, size)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete deletes a package blob
 | 
			
		||||
func (s *ContentStore) Delete(key BlobHash256Key) error {
 | 
			
		||||
	return s.store.Delete(keyToRelativePath(key))
 | 
			
		||||
	return s.store.Delete(KeyToRelativePath(key))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// keyToRelativePath converts the sha256 key aabb000000... to aa/bb/aabb000000...
 | 
			
		||||
func keyToRelativePath(key BlobHash256Key) string {
 | 
			
		||||
// KeyToRelativePath converts the sha256 key aabb000000... to aa/bb/aabb000000...
 | 
			
		||||
func KeyToRelativePath(key BlobHash256Key) string {
 | 
			
		||||
	return path.Join(string(key)[0:2], string(key)[2:4], string(key))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user