Skip to content

Commit 5e4190c

Browse files
committed
Removed db.GetAllMetaDataIds()
1 parent 70e34df commit 5e4190c

File tree

7 files changed

+1
-62
lines changed

7 files changed

+1
-62
lines changed

internal/configuration/database/Database.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ func GetAllMetadata() map[string]models.File {
189189
return db.GetAllMetadata()
190190
}
191191

192-
// GetAllMetaDataIds returns all Ids that contain metadata
193-
func GetAllMetaDataIds() []string {
194-
return db.GetAllMetaDataIds()
195-
}
196-
197192
// GetMetaDataById returns a models.File from the ID passed or false if the id is not valid
198193
func GetMetaDataById(id string) (models.File, bool) {
199194
return db.GetMetaDataById(id)

internal/configuration/database/Database_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestE2E(t *testing.T) {
131131
input.AvailableFiles = nil
132132
runAllTypesCompareOutput(t, func() any { return GetEnd2EndInfo(3) }, input)
133133
runAllTypesNoOutput(t, func() { DeleteEnd2EndInfo(3) })
134-
runAllTypesCompareOutput(t, func() any { return GetEnd2EndInfo(3) }, models.E2EInfoEncrypted{AvailableFiles: nil})
134+
runAllTypesCompareOutput(t, func() any { return GetEnd2EndInfo(3) }, models.E2EInfoEncrypted{})
135135
}
136136

137137
func TestSessions(t *testing.T) {
@@ -208,7 +208,6 @@ func TestHotlinks(t *testing.T) {
208208
}
209209

210210
func TestMetaData(t *testing.T) {
211-
runAllTypesCompareOutput(t, func() any { return GetAllMetaDataIds() }, []string{})
212211
runAllTypesCompareOutput(t, func() any { return GetAllMetadata() }, map[string]models.File{})
213212
runAllTypesCompareTwoOutputs(t, func() (any, any) { return GetMetaDataById("testid") }, models.File{}, false)
214213
file := models.File{
@@ -238,10 +237,8 @@ func TestMetaData(t *testing.T) {
238237
}
239238
runAllTypesNoOutput(t, func() { SaveMetaData(file) })
240239
runAllTypesCompareTwoOutputs(t, func() (any, any) { return GetMetaDataById("testid") }, file, true)
241-
runAllTypesCompareOutput(t, func() any { return GetAllMetaDataIds() }, []string{"testid"})
242240
runAllTypesCompareOutput(t, func() any { return GetAllMetadata() }, map[string]models.File{"testid": file})
243241
runAllTypesNoOutput(t, func() { DeleteMetaData("testid") })
244-
runAllTypesCompareOutput(t, func() any { return GetAllMetaDataIds() }, []string{})
245242
runAllTypesCompareOutput(t, func() any { return GetAllMetadata() }, map[string]models.File{})
246243
runAllTypesCompareTwoOutputs(t, func() (any, any) { return GetMetaDataById("testid") }, models.File{}, false)
247244

internal/configuration/database/dbabstraction/DbAbstraction.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ type Database interface {
6666

6767
// GetAllMetadata returns a map of all available files
6868
GetAllMetadata() map[string]models.File
69-
// GetAllMetaDataIds returns all Ids that contain metadata
70-
GetAllMetaDataIds() []string
7169
// GetMetaDataById returns a models.File from the ID passed or false if the id is not valid
7270
GetMetaDataById(id string) (models.File, bool)
7371
// SaveMetaData stores the metadata of a file to the disk

internal/configuration/database/provider/redis/Redis_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -509,19 +509,6 @@ func TestMetaData(t *testing.T) {
509509
_ = dbInstance.GetAllMetadata()
510510
}
511511

512-
func TestGetAllMetaDataIds(t *testing.T) {
513-
instance, err := New(config)
514-
test.IsNil(t, err)
515-
516-
ids := instance.GetAllMetaDataIds()
517-
test.IsEqualString(t, ids[0], "test2")
518-
test.IsEqualString(t, ids[1], "test3")
519-
520-
instance.Close()
521-
defer test.ExpectPanic(t)
522-
_ = instance.GetAllMetaDataIds()
523-
}
524-
525512
func TestUsers(t *testing.T) {
526513
instance, err := New(config)
527514
test.IsNil(t, err)

internal/configuration/database/provider/redis/metadata.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ func unmarshalEncryptionInfo(f models.File) (models.File, error) {
6363
return f, nil
6464
}
6565

66-
// GetAllMetaDataIds returns all Ids that contain metadata
67-
func (p DatabaseProvider) GetAllMetaDataIds() []string {
68-
result := make([]string, 0)
69-
for _, key := range p.getAllKeysWithPrefix(prefixMetaData) {
70-
result = append(result, strings.Replace(key, prefixMetaData, "", 1))
71-
}
72-
return result
73-
}
74-
7566
// GetMetaDataById returns a models.File from the ID passed or false if the id is not valid
7667
func (p DatabaseProvider) GetMetaDataById(id string) (models.File, bool) {
7768
result, ok := p.getHashMap(prefixMetaData + id)

internal/configuration/database/provider/sqlite/Sqlite_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,6 @@ func TestDatabaseProvider_GetType(t *testing.T) {
128128
test.IsEqualInt(t, dbInstance.GetType(), 0)
129129
}
130130

131-
func TestGetAllMetaDataIds(t *testing.T) {
132-
instance, err := New(config)
133-
test.IsNil(t, err)
134-
dbInstance = instance
135-
136-
ids := dbInstance.GetAllMetaDataIds()
137-
test.IsEqualString(t, ids[0], "test2")
138-
test.IsEqualString(t, ids[1], "test3")
139-
140-
dbInstance.Close()
141-
defer test.ExpectPanic(t)
142-
_ = dbInstance.GetAllMetaDataIds()
143-
}
144-
145131
func TestHotlink(t *testing.T) {
146132
instance, err := New(config)
147133
test.IsNil(t, err)

internal/configuration/database/provider/sqlite/metadata.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,6 @@ func (p DatabaseProvider) GetAllMetadata() map[string]models.File {
8181
return result
8282
}
8383

84-
// GetAllMetaDataIds returns all Ids that contain metadata
85-
func (p DatabaseProvider) GetAllMetaDataIds() []string {
86-
keys := make([]string, 0)
87-
rows, err := p.sqliteDb.Query("SELECT Id FROM FileMetaData")
88-
helper.Check(err)
89-
defer rows.Close()
90-
for rows.Next() {
91-
rowData := schemaMetaData{}
92-
err = rows.Scan(&rowData.Id)
93-
helper.Check(err)
94-
keys = append(keys, rowData.Id)
95-
}
96-
return keys
97-
}
98-
9984
// GetMetaDataById returns a models.File from the ID passed or false if the id is not valid
10085
func (p DatabaseProvider) GetMetaDataById(id string) (models.File, bool) {
10186
result := models.File{}

0 commit comments

Comments
 (0)