-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.go
76 lines (53 loc) · 1.7 KB
/
vault.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Vault main struct
package main
import "path"
// Vault main data struct
type Vault struct {
path string // Vault path
credentials *VaultCredentialsManager // Manages vault credentials
sessions *SessionManager // Manages active user sessions
invites *InvitationManager // Manages invite codes
media *MediaAssetsManager // Media assets
tasks *TaskManager // Manages media encoding tasks
index *VaultMainIndex // Main index with all media assets
tags *VaultTagManager // Tags (unsorted lists)
albums *VaultAlbumsManager // Albums (sorted lists)
config *UserConfigManager // User config
}
// Vault initialization process
// base_path - Vault path
// preview_cache_size - Max size of the preview cache
func (vault *Vault) Initialize(base_path string, preview_cache_size int) error {
vault.path = base_path
vault.credentials = &VaultCredentialsManager{}
err := vault.credentials.Initialize(base_path)
if err != nil {
return err
}
vault.sessions = &SessionManager{}
vault.sessions.Initialize(vault)
vault.invites = &InvitationManager{}
vault.invites.Initialize(vault)
vault.media = &MediaAssetsManager{}
vault.media.Initialize(base_path, preview_cache_size)
vault.tasks = &TaskManager{}
err = vault.tasks.Initialize(base_path, vault)
if err != nil {
return err
}
vault.index = &VaultMainIndex{}
err = vault.index.Initialize(path.Join(base_path, "main.index"))
if err != nil {
return err
}
vault.tags = &VaultTagManager{}
err = vault.tags.Initialize(base_path)
if err != nil {
return err
}
vault.albums = &VaultAlbumsManager{}
vault.albums.Initialize(base_path)
vault.config = &UserConfigManager{}
vault.config.Initialize(base_path)
return nil
}