Skip to content

Commit

Permalink
Expose deletion from the index; use from admin fns.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed May 29, 2015
1 parent c6a346a commit 6327f44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/clojars/admin.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns clojars.admin
(:require [clojars.config :refer [config]]
[clojars.db :as db]
[clojars.search :as search]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.tools.nrepl.server :as nrepl])
Expand Down Expand Up @@ -40,7 +41,8 @@
(println "Deleting" group-id)
(repo->backup [group-id])
(db/delete-jars group-id)
(db/delete-groups group-id)))
(db/delete-groups group-id)
(search/delete-from-index group-id)))
(println "No group found under" group-id)))

(defn delete-jars [group-id jar-id & [version]]
Expand All @@ -56,7 +58,8 @@
(fn []
(println "Deleting" pretty-coords)
(repo->backup [group-id jar-id version])
(apply db/delete-jars group-id jar-id (if version [version] []))))
(apply db/delete-jars group-id jar-id (if version [version] []))
(search/delete-from-index group-id jar-id)))
(println "No artifacts found under" group-id jar-id version))))

(defn init []
Expand Down
6 changes: 6 additions & 0 deletions src/clojars/search.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@

(def renames {:name :artifact-id :group :group-id})

(defn delete-from-index [group-id & [artifact-id]]
(with-open [index (clucy/disk-index (config :index-path))]
(clucy/search-and-delete index
(cond-> (str "group-id:" group-id)
artifact-id (str " AND artifact-id:" artifact-id)))))

(defn index-pom [index pom-file]
(let [pom (-> (mvn/pom-to-map pom-file)
(set/rename-keys renames)
Expand Down

0 comments on commit 6327f44

Please sign in to comment.