@@ -72,10 +72,8 @@ func setupStore(c *cli.Context) (store.Store, error) {
72
72
}
73
73
74
74
if driver == "sqlite3" {
75
- if newDatasource , err := fallbackSqlite3File (datasource ); err != nil {
76
- log .Fatal ().Err (err ).Msg ("fallback to old sqlite3 file failed" )
77
- } else {
78
- datasource = newDatasource
75
+ if err := checkSqliteFileExist (datasource ); err != nil {
76
+ log .Fatal ().Err (err ).Msg ("check sqlite file" )
79
77
}
80
78
}
81
79
@@ -97,69 +95,13 @@ func setupStore(c *cli.Context) (store.Store, error) {
97
95
return store , nil
98
96
}
99
97
100
- // TODO: remove it in v1.1.0
101
- // TODO: add it to the "how to migrate from drone docs"
102
- func fallbackSqlite3File (path string ) (string , error ) {
103
- const dockerDefaultPath = "/var/lib/woodpecker/woodpecker.sqlite"
104
- const dockerDefaultDir = "/var/lib/woodpecker/drone.sqlite"
105
- const dockerOldPath = "/var/lib/drone/drone.sqlite"
106
- const standaloneDefault = "woodpecker.sqlite"
107
- const standaloneOld = "drone.sqlite"
108
-
109
- // custom location was set, use that one
110
- if path != dockerDefaultPath && path != standaloneDefault {
111
- return path , nil
112
- }
113
-
114
- // file is at new default("/var/lib/woodpecker/woodpecker.sqlite")
115
- _ , err := os .Stat (dockerDefaultPath )
116
- if err != nil && ! os .IsNotExist (err ) {
117
- return "" , err
118
- }
119
- if err == nil {
120
- return dockerDefaultPath , nil
98
+ func checkSqliteFileExist (path string ) error {
99
+ _ , err := os .Stat (path )
100
+ if err != nil && os .IsNotExist (err ) {
101
+ log .Warn ().Msgf ("no sqlite3 file found, will create one at '%s'" , path )
102
+ return nil
121
103
}
122
-
123
- // file is at new default("woodpecker.sqlite")
124
- _ , err = os .Stat (standaloneDefault )
125
- if err != nil && ! os .IsNotExist (err ) {
126
- return "" , err
127
- }
128
- if err == nil {
129
- return standaloneDefault , nil
130
- }
131
-
132
- // woodpecker run in standalone mode, file is in same folder but not renamed
133
- _ , err = os .Stat (standaloneOld )
134
- if err != nil && ! os .IsNotExist (err ) {
135
- return "" , err
136
- }
137
- if err == nil {
138
- // rename in same folder should be fine as it should be same docker volume
139
- log .Warn ().Msgf ("found sqlite3 file at '%s' and moved to '%s'" , standaloneOld , standaloneDefault )
140
- return standaloneDefault , os .Rename (standaloneOld , standaloneDefault )
141
- }
142
-
143
- // file is in new folder but not renamed
144
- _ , err = os .Stat (dockerDefaultDir )
145
- if err != nil && ! os .IsNotExist (err ) {
146
- return "" , err
147
- }
148
- if err == nil {
149
- // rename in same folder should be fine as it should be same docker volume
150
- log .Warn ().Msgf ("found sqlite3 file at '%s' and moved to '%s'" , dockerDefaultDir , dockerDefaultPath )
151
- return dockerDefaultPath , os .Rename (dockerDefaultDir , dockerDefaultPath )
152
- }
153
-
154
- // file is still at old location
155
- _ , err = os .Stat (dockerOldPath )
156
- if err == nil {
157
- log .Fatal ().Msgf ("found sqlite3 file at old path '%s', please move it to '%s' and update your volume path if necessary" , dockerOldPath , dockerDefaultPath )
158
- }
159
-
160
- // file does not exist at all
161
- log .Warn ().Msgf ("no sqlite3 file found, will create one at '%s'" , path )
162
- return path , nil
104
+ return err
163
105
}
164
106
165
107
func setupQueue (c * cli.Context , s store.Store ) queue.Queue {
0 commit comments