Skip to content

Commit

Permalink
Make it usable
Browse files Browse the repository at this point in the history
  • Loading branch information
pb- committed Jan 7, 2024
1 parent bbccc3b commit a372419
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ develop:
test:
clojure -X:test
.PHONY: test

release:
clojure -T:build uber
cat build/stub.sh target/unsplice-mbox.jar > target/unsplice-mbox
chmod a+x target/unsplice-mbox
.PHONY: release
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ Attachments are decoded (typically from base64) and stored in a content-addressa
unsplice-mbox was primarily tested with a single Gmail takeout containing about 100K emails over a span of 20 years. While this contained many different edge cases, it is unlikely that all situations are being handled. Feel free to open an issue or submit a patch if you encounter some parsing errors.


## Download/installation

You can get a [prebuilt release](releases/) (Java JRE required) or build it yourself (requires a JDK and Clojure):

```shell
make release
ls target/unsplice-mbox
```


## Usage

```shell
# will put attachments into output-mbox.d/
unsplice-mbox input-mbox output-mbox
```


## Rationale

Making incremental backups of recurring Gmail takeouts is fairly inefficient because the takeout is a single large file and not append-only.
19 changes: 19 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns build
(:require [clojure.tools.build.api :as b]))

(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file (format "target/unsplice-mbox.jar"))

(defn clean [_]
(b/delete {:path "target"}))

(defn uber [_]
(clean nil)
(b/compile-clj {:basis basis
:src-dirs ["src"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis
:main 'unsplice.core}))
12 changes: 12 additions & 0 deletions build/stub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

SELF=$(which "$0" 2> /dev/null)
[ $? -gt 0 -a -f "$0" ] && SELF="./$0"

java=java
if test -n "$JAVA_HOME"; then
java="$JAVA_HOME/bin/java"
fi

exec "$java" -jar $SELF "$@"
exit 1
6 changes: 5 additions & 1 deletion src/unsplice/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
[java.security MessageDigest DigestOutputStream]
[jakarta.mail.internet MimeUtility]
[dev.baecher.io BoundaryInputStream]
[org.apache.commons.codec.binary Base64InputStream]))
[org.apache.commons.codec.binary Base64InputStream])
(:gen-class))

(def version "0.9.0")

(def cr-lf (.getBytes "\r\n" "ASCII"))
(def dash-dash (.getBytes "--" "ASCII"))
Expand Down Expand Up @@ -198,6 +201,7 @@
(println "finished" mail-number "mails")))))))

(defn -main [& args]
(println "unsplice-mbox " version)
(when-not (= 2 (count args))
(println "arguments required: INPUT-FILE OUTPUT-FILE")
(System/exit -1))
Expand Down

0 comments on commit a372419

Please sign in to comment.