-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserdata.nim
39 lines (28 loc) · 849 Bytes
/
userdata.nim
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
import zippy, zippy/ziparchives
import os
import re
import tables
let whiteList = @[
#re"((images(/.*)?)|static|media|library|logs|subtitles|thumbnails|\.htaccess|\.conf)$",
re"((images/.*)|(fonts/.*)|static/|media/|library/|logs/.*|subtitles/|thumbnails/|\.htaccess|\.conf|\.types)$",
]
proc whitelisted(path: string): bool =
for pattern in whiteList:
if pattern in path: return true
false
proc writeUserDataTemplate* =
var t = ZipArchive()
t.addDir("userdata")
var ignoreFiles = newSeq[string]()
for key in t.contents.keys:
if not whitelisted(key):
#echo "discarding ", key
ignoreFiles.add(key)
else:
echo "keeping ", key
for f in ignoreFiles:
t.contents.del(f)
t.writeZipArchive("dist/userdata.zip")
#t.writeZipArchive("/tmp/test.zip")
when isMainModule:
writeUserDataTemplate()