Browse Source

Use previous blog post index when deleting

Bob Mottram 8 years ago
parent
commit
f15a234346
No account linked to committer's email
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/freedombone-mesh-blog

+ 5
- 2
src/freedombone-mesh-blog View File

@@ -105,7 +105,8 @@ function delete_blog {
105 105
         return
106 106
     fi
107 107
     CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX)
108
-    LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.rst
108
+    PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
109
+    LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.rst
109 110
     if [ ! -f $LAST_BLOG_ENTRY ]; then
110 111
         return
111 112
     fi
@@ -118,8 +119,10 @@ function delete_blog {
118 119
     case $sel in
119 120
         0) rm $LAST_BLOG_ENTRY
120 121
            if [ $CURRENT_INDEX -gt 0 ]; then
121
-               CURRENT_INDEX=$((CURRENT_INDEX - 1))
122
+               CURRENT_INDEX=$PREVIOUS_INDEX
122 123
                echo "$CURRENT_INDEX" > $CURRENT_BLOG_INDEX
124
+           else
125
+               rm -f $CURRENT_BLOG_INDEX
123 126
            fi
124 127
            regenerate_blog
125 128
            ;;