@@ -16,7 +16,7 @@ import (
16
16
)
17
17
18
18
const (
19
- softVersion = "1.2.4 "
19
+ softVersion = "1.3.0 "
20
20
dumpDir = "dump"
21
21
)
22
22
@@ -75,6 +75,7 @@ func main() {
75
75
76
76
var opts struct {
77
77
Build string `short:"b" long:"build" description:"Select build type: stable, ptb, canary, development"`
78
+ Flatpak bool `short:"f" long:"flatpak" description:"Target flatpak builds (Linux only)"`
78
79
Noninteractive bool `short:"n" long:"noninteractive" description:"Non-interactive -- no 'enter' key required"`
79
80
}
80
81
@@ -189,11 +190,20 @@ func main() {
189
190
fmt .Scanln ()
190
191
}
191
192
193
+ flatpakMode := opts .Flatpak && platform == "linux"
194
+ if flatpakMode {
195
+ fmt .Print ("Flatpak mode\n " )
196
+ }
197
+
192
198
fmt .Print ("Checking for existing cache directories ...\n \n " )
193
199
194
200
// Check if directories exist
195
201
for i := 0 ; i < len (discordBuildDir ); i ++ {
196
- filePath := fmt .Sprintf (cachePath [platform ], homePath , discordBuildDir [i ])
202
+ filePathRaw := cachePath [platform ]
203
+ if flatpakMode {
204
+ filePathRaw = DCDUtils .FlatpakPath (discordBuildDir [i ])
205
+ }
206
+ filePath := fmt .Sprintf (filePathRaw , homePath , discordBuildDir [i ])
197
207
if _ , err := os .Stat (filePath ); ! os .IsNotExist (err ) {
198
208
fmt .Printf ("Found: Discord %s\n " , discordBuildName [i ])
199
209
pathStatus [i ] = true
@@ -205,7 +215,11 @@ func main() {
205
215
// Check if the directories are empty and store names of cached files
206
216
for i := 0 ; i < len (discordBuildDir ); i ++ {
207
217
if pathStatus [i ] {
208
- filePath := fmt .Sprintf (cachePath [platform ], homePath , discordBuildDir [i ])
218
+ filePathRaw := cachePath [platform ]
219
+ if flatpakMode {
220
+ filePathRaw = DCDUtils .FlatpakPath (discordBuildDir [i ])
221
+ }
222
+ filePath := fmt .Sprintf (filePathRaw , homePath , discordBuildDir [i ])
209
223
cacheListing , err := ioutil .ReadDir (filePath )
210
224
if err != nil {
211
225
fmt .Printf ("[ERROR] Unable to read directory for Discord %s%s" , discordBuildName [i ], DCDUtils .ExitNewLine ())
@@ -216,7 +230,7 @@ func main() {
216
230
cachedFile [i ] = make (map [int ]string )
217
231
for k , v := range cacheListing {
218
232
cachedFile [i ][k ] = v .Name ()
219
- overallSize = DCDUtils .SizeStore (filePath + v .Name (), overallSize )
233
+ overallSize = DCDUtils .SizeStore (filePath + v .Name (), overallSize )
220
234
}
221
235
fmt .Printf ("Discord %s :: found %d cached files\n " , discordBuildName [i ], len (cacheListing ))
222
236
} else {
@@ -286,7 +300,11 @@ func main() {
286
300
fmt .Printf ("Copying %d files from Discord %s ...\n " , len (cachedFile [i ]), discordBuildName [i ])
287
301
for it := 0 ; it < len (cachedFile [i ]); it ++ {
288
302
// Build the paths to use during the copy operation
289
- fromPath := fmt .Sprintf (cachePath [platform ], homePath , discordBuildDir [i ])
303
+ filePathRaw := cachePath [platform ]
304
+ if flatpakMode {
305
+ filePathRaw = DCDUtils .FlatpakPath (discordBuildDir [i ])
306
+ }
307
+ fromPath := fmt .Sprintf (filePathRaw , homePath , discordBuildDir [i ])
290
308
toPath := dumpDir + "/" + timeDateStamp + "/" + discordBuildName [i ] + "/" + cachedFile [i ][it ]
291
309
// Copying the files one-by-one
292
310
unreadableRes = DCDUtils .CopyFile (fromPath + cachedFile [i ][it ], toPath , sudoerUID , unreadableRes )
0 commit comments