Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
631a618e
Unverified
Commit
631a618e
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Copy newer versions of modules when launching
parent
4480b24b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/plugins.clj
+1
-1
1 addition, 1 deletion
src/metabase/plugins.clj
src/metabase/plugins/files.clj
+17
-11
17 additions, 11 deletions
src/metabase/plugins/files.clj
with
18 additions
and
12 deletions
src/metabase/plugins.clj
+
1
−
1
View file @
631a618e
...
...
@@ -54,7 +54,7 @@
(
when
(
io/resource
"modules"
)
(
let
[
plugins-path
(
plugins-dir
)]
(
files/with-open-path-to-resource
[
modules-path
"modules"
]
(
files/copy-files
-if-not-exists
!
modules-path
plugins-path
)))))
(
files/copy-files!
modules-path
plugins-path
)))))
;;; +----------------------------------------------------------------------------------------------------------------+
...
...
This diff is collapsed.
Click to expand it.
src/metabase/plugins/files.clj
+
17
−
11
View file @
631a618e
...
...
@@ -7,14 +7,15 @@
*file-manipulation* functions for the sorts of operations the plugin system needs to perform."
(
:require
[
clojure.java.io
:as
io
]
[
clojure.string
:as
str
]
[
clojure.tools.logging
:as
log
]
[
metabase.util
:as
u
]
[
metabase.util
[
date
:as
du
]
[
i18n
:refer
[
trs
]]])
(
:import
java.io.FileNotFoundException
java.net.URL
[
java.nio.file
CopyOption
Files
FileSystem
FileSystems
LinkOption
OpenOption
Path
]
java.nio.file.attribute
.
FileAttribute
[
java.nio.file
CopyOption
Files
FileSystem
FileSystems
LinkOption
OpenOption
Path
StandardCopyOption
]
[
java.nio.file.attribute
FileAttribute
FileTime
]
java.util.Collections
))
;;; --------------------------------------------------- Path Utils ---------------------------------------------------
...
...
@@ -69,20 +70,25 @@
;;; ------------------------------------------------- Copying Stuff --------------------------------------------------
(
defn-
copy!
[
^
Path
source,
^
Path
dest
]
(
du/profile
(
trs
"Extract file {0} -> {1}"
source
dest
)
(
Files/copy
source
dest
(
u/varargs
CopyOption
))))
(
defn-
last-modified-time
^
FileTime
[
^
Path
path
]
(
Files/getLastModifiedTime
path
(
u/varargs
LinkOption
)))
(
defn-
copy-if-not-exists!
[
^
Path
source,
^
Path
dest
]
(
when-not
(
exists?
dest
)
(
copy!
source
dest
)))
(
defn-
copy-file!
[
^
Path
source,
^
Path
dest
]
(
when
(
or
(
not
(
exists?
dest
))
(
pos?
(
.compareTo
(
last-modified-time
source
)
(
last-modified-time
dest
))))
(
du/profile
(
trs
"Extract file {0} -> {1}"
source
dest
)
(
Files/copy
source
dest
(
u/varargs
CopyOption
[
StandardCopyOption/REPLACE_EXISTING
])))))
(
defn
copy-files-if-not-exists!
"Copy all files in `source-dir` to `dest-dir`; skip files if a file of the same name already exists in `dest-dir`."
(
defn
copy-files!
"Copy all files in `source-dir` to `dest-dir`. Overwrites existing files if last modified date is older than that of
the source file."
[
^
Path
source-dir,
^
Path
dest-dir
]
(
doseq
[
^
Path
source
(
files-seq
source-dir
)
:let
[
target
(
append-to-path
dest-dir
(
str
(
.getFileName
source
)))]]
(
copy-if-not-exists!
source
target
)))
(
try
(
copy-file!
source
target
)
(
catch
Throwable
e
(
log/error
e
(
trs
"Failed to copy file"
))))))
;;; ------------------------------------------ Opening filesystems for URLs ------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment