Commit
This commit is contained in:
		
							
								
								
									
										22
									
								
								boltease.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								boltease.go
									
									
									
									
									
								
							@@ -78,6 +78,10 @@ func SetStructList[T any](b *DB, path []string, values []T, fn func(*bolt.Bucket
 | 
				
			|||||||
		defer b.CloseDB()
 | 
							defer b.CloseDB()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// We remove the bucket, if it already exists
 | 
				
			||||||
 | 
						bktPth, bktNm := path[:len(path)-2], path[len(path)-1]
 | 
				
			||||||
 | 
						b.DeleteBucket(bktPth, bktNm)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = b.MkBucketPath(path)
 | 
						err = b.MkBucketPath(path)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
@@ -93,11 +97,8 @@ func SetStructList[T any](b *DB, path []string, values []T, fn func(*bolt.Bucket
 | 
				
			|||||||
				return err
 | 
									return err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// bkt should have the last bucket in the path
 | 
							// bkt should have the last bucket in the path
 | 
				
			||||||
		// We need to get the sequence number, if it's greater than the length of
 | 
					 | 
				
			||||||
		// 'values', we're going to have to delete values.
 | 
					 | 
				
			||||||
		seq := bkt.Sequence()
 | 
					 | 
				
			||||||
		bkt.SetSequence(0)
 | 
					 | 
				
			||||||
		for _, v := range values {
 | 
							for _, v := range values {
 | 
				
			||||||
			id, _ := bkt.NextSequence()
 | 
								id, _ := bkt.NextSequence()
 | 
				
			||||||
			bId := make([]byte, 8)
 | 
								bId := make([]byte, 8)
 | 
				
			||||||
@@ -107,15 +108,6 @@ func SetStructList[T any](b *DB, path []string, values []T, fn func(*bolt.Bucket
 | 
				
			|||||||
				return err
 | 
									return err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		currSeq := bkt.Sequence()
 | 
					 | 
				
			||||||
		for ; seq < currSeq; seq++ {
 | 
					 | 
				
			||||||
			bId := make([]byte, 8)
 | 
					 | 
				
			||||||
			binary.BigEndian.PutUint64(bId, seq)
 | 
					 | 
				
			||||||
			err = bkt.Delete(bId)
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				return err
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return err
 | 
						return err
 | 
				
			||||||
@@ -498,6 +490,9 @@ func (b *DB) DeletePair(path []string, key string) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// DeleteBucket deletes the bucket key at path
 | 
					// DeleteBucket deletes the bucket key at path
 | 
				
			||||||
func (b *DB) DeleteBucket(path []string, key string) error {
 | 
					func (b *DB) DeleteBucket(path []string, key string) error {
 | 
				
			||||||
 | 
						if len(path) == 0 {
 | 
				
			||||||
 | 
							return errors.New("no path")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	if !b.dbIsOpen {
 | 
						if !b.dbIsOpen {
 | 
				
			||||||
		if err = b.OpenDB(); err != nil {
 | 
							if err = b.OpenDB(); err != nil {
 | 
				
			||||||
@@ -578,7 +573,6 @@ func (b *DB) SetStringList(path, values []string) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// We remove the bucket, if it already exists
 | 
						// We remove the bucket, if it already exists
 | 
				
			||||||
	bktPth, bktNm := path[:len(path)-2], path[len(path)-1]
 | 
						bktPth, bktNm := path[:len(path)-2], path[len(path)-1]
 | 
				
			||||||
	fmt.Println("Deleting Bucket:", bktPth, bktNm)
 | 
					 | 
				
			||||||
	b.DeleteBucket(bktPth, bktNm)
 | 
						b.DeleteBucket(bktPth, bktNm)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = b.MkBucketPath(path)
 | 
						err = b.MkBucketPath(path)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user