From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ag:master commit in: /, lib/
Date: Tue, 24 Feb 2015 02:00:12 +0000 (UTC) [thread overview]
Message-ID: <1424742547.149ce341820a66010e8592975d86e5d6dd0c6b7e.robbat2@gentoo> (raw)
commit: 149ce341820a66010e8592975d86e5d6dd0c6b7e
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 01:47:30 2015 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 01:49:07 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=149ce341
Expose delete index.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
ag | 23 +++++++++++++++++++----
lib/storage.rb | 11 +++++++++--
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/ag b/ag
index c5056ff..4636675 100755
--- a/ag
+++ b/ag
@@ -27,7 +27,7 @@ $options.readonly = false
$options.jobs = false
op = OptionParser.new do |opts|
- opts.banner = "Usage: ag <<--index-full|--index-new|--delete|--reindex|--info> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]"
+ opts.banner = "Usage: ag <<--index-full|--index-new|--delete-msg|--delete-index|--reindex|--info> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]"
opts.on('--index-full', 'Read the full past archive from the .cur Maildir') do
abort 'Can only select one action' if $options.action != nil
@@ -41,10 +41,16 @@ op = OptionParser.new do |opts|
$options.action = :do_incremental
end
- opts.on('--delete', 'Delete message. Needs --file, --msgid, or --hash') do
+ opts.on('--delete-msg', 'Delete message. Needs --file, --msgid, or --hash') do
abort 'Can only select one action' if $options.action != nil
- $options.action = :do_delete
+ $options.action = :do_delete_msg
+ end
+
+ opts.on('--delete-Index', 'Delete index. Needs --list') do
+ abort 'Can only select one action' if $options.action != nil
+
+ $options.action = :do_index
end
opts.on('--info', 'Display message details. Needs --file, --msgid, or --hash') do
@@ -156,7 +162,7 @@ def do_incremental
Ag::Threading.calc($options.name) unless $options.no_threading
end
-def do_delete
+def do_delete_msg
id = Ag::Utils.resolve_id
begin
@@ -166,6 +172,15 @@ def do_delete
end
end
+def do_delete_index
+ begin
+ Ag::Storage.delete_index($options.name)
+ rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
+ rescue => e
+ $stderr.puts "Cannot delete index: #{e}"
+ end
+end
+
def do_reindex
abort 'Come back later.'
end
diff --git a/lib/storage.rb b/lib/storage.rb
index 5b360f5..656a6bf 100644
--- a/lib/storage.rb
+++ b/lib/storage.rb
@@ -3,9 +3,16 @@ require 'date'
module Ag::Storage
module_function
+
+ # Throws Elasticsearch::Transport::Transport::Errors::NotFound
+ # if the list does not exist
+ def delete_index(list)
+ $es.indices.delete index: 'ml-' + list
+ end
+
def create_index(list)
begin
- $es.indices.delete index: 'ml-' + list
+ delete_index(ist)
rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
$stderr.puts "Index did not exist yet. Creating." if $options.debug
end
@@ -267,4 +274,4 @@ module Ag::Storage
return nil if result['hits']['total'] == 0
result['hits']['hits'].first
end
-end
\ No newline at end of file
+end
next reply other threads:[~2015-02-24 2:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 2:00 Robin H. Johnson [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-02-24 2:17 [gentoo-commits] proj/ag:master commit in: /, lib/ Robin H. Johnson
2015-02-23 22:44 Robin H. Johnson
2015-02-23 20:59 Alex Legler
2015-02-23 0:05 Alex Legler
2015-02-23 0:05 Alex Legler
2015-02-21 21:45 Robin H. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424742547.149ce341820a66010e8592975d86e5d6dd0c6b7e.robbat2@gentoo \
--to=robbat2@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox