@@ -115,7 +115,7 @@ func searchByExt(c *cli.Context, filename string) error {
115115 }
116116 defer db .Close ()
117117
118- r , err := hsdb .Search (db , filename , []string {ext }, limit )
118+ r , err := hsdb .Search (db , filename , []string {ext }, [] string {}, limit )
119119 for _ , result := range r {
120120 printFileResult (result )
121121 }
@@ -125,27 +125,18 @@ func searchByExt(c *cli.Context, filename string) error {
125125
126126func searchByHost (c * cli.Context , filename string ) error {
127127 host := c .String ("host" )
128- limit := c .String ("limit" )
128+ limit := c .Int ("limit" )
129129 db , err := dbConn (c .String ("db" ))
130130 if err != nil {
131131 return fmt .Errorf ("failed to get database connection: %v" , err )
132132 }
133133 defer db .Close ()
134134
135- query := `
136- SELECT file_path, file_size, modified_date, host, extension, file_hash
137- FROM file_info
138- WHERE (file_path LIKE ? OR file_hash LIKE ?) AND host = ?
139- LIMIT ?
140- `
141-
142- rows , err := db .Query (query , "%" + filename + "%" , "%" + filename + "%" , host , limit )
143- if err != nil {
144- return fmt .Errorf ("failed to query database: %v" , err )
135+ r , err := hsdb .Search (db , filename , []string {}, []string {host }, limit )
136+ for _ , result := range r {
137+ printFileResult (result )
145138 }
146- defer rows .Close ()
147-
148- return printRows (rows )
139+ return nil
149140}
150141
151142func searchFiles (c * cli.Context , filename string ) error {
@@ -155,7 +146,7 @@ func searchFiles(c *cli.Context, filename string) error {
155146 }
156147 defer db .Close ()
157148
158- r , err := hsdb .Search (db , filename , []string {}, 100 )
149+ r , err := hsdb .Search (db , filename , []string {}, [] string {}, 100 )
159150 for _ , result := range r {
160151 printFileResult (result )
161152 }
0 commit comments