@@ -17,15 +17,18 @@ const (
1717)
1818
1919// MakeRecursive creates path inside database
20- func MakeRecursive (ctx context.Context , db ydb.Connection , folder string ) error {
21- folder = path .Join (db .Name (), folder )
22- for i := len (db .Name ()) + 1 ; i < len (folder ); i ++ {
23- x := strings .IndexByte (folder [i :], '/' )
20+ // folder is a database root relative path
21+ // MakeRecursive method equal bash command `mkdir -p ~/path/to/create`
22+ // where `~` - is a root of database
23+ func MakeRecursive (ctx context.Context , db ydb.Connection , pathToCreate string ) error {
24+ pathToCreate = path .Join (db .Name (), pathToCreate )
25+ for i := len (db .Name ()) + 1 ; i < len (pathToCreate ); i ++ {
26+ x := strings .IndexByte (pathToCreate [i :], '/' )
2427 if x == - 1 {
25- x = len (folder [i :]) - 1
28+ x = len (pathToCreate [i :]) - 1
2629 }
2730 i += x
28- sub := folder [:i + 1 ]
31+ sub := pathToCreate [:i + 1 ]
2932 info , err := db .Scheme ().DescribePath (ctx , sub )
3033 var opErr * errors.OpError
3134 if errors .As (err , & opErr ) && opErr .Reason == errors .StatusSchemeError {
@@ -54,9 +57,11 @@ func MakeRecursive(ctx context.Context, db ydb.Connection, folder string) error
5457}
5558
5659// RemoveRecursive remove selected directory or table names in database.
60+ // pathToRemove is a database root relative path
5761// All database entities in prefix path will remove if names list is empty.
5862// Empty prefix means than use root of database.
59- // RemoveRecursive method equal bash command `rm -rf ./path/to/remove`
63+ // RemoveRecursive method equal bash command `rm -rf ~/path/to/remove`
64+ // where `~` - is a root of database
6065func RemoveRecursive (ctx context.Context , db ydb.Connection , pathToRemove string ) error {
6166 fullSysTablePath := path .Join (db .Name (), sysTable )
6267 var list func (int , string ) error
0 commit comments