Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'staging' into 'master'
Add ability to export any snapshot as file tree See merge request !1
- Loading branch information
Showing
8 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import QtQuick 2.0 | ||
import NemoMobile.Vault 1.1 | ||
|
||
QtObject { | ||
property Vault vault: Vault { | ||
onDone: vaultOperationDone(operation, data) | ||
onProgress: vaultOperationProgress(operation, data) | ||
onError: vaultOperationError(operation, error) | ||
onData: vaultData(id, context) | ||
} | ||
|
||
// event handlers | ||
|
||
function vaultOperationDone(operation, data) { | ||
console.log("vault operation", operation, "done") | ||
var action | ||
switch (operation) { | ||
case Vault.Connect: | ||
break | ||
case Vault.Maintenance: | ||
break | ||
case Vault.Backup: | ||
break | ||
case Vault.Restore: | ||
break | ||
case Vault.RemoveSnapshot: | ||
break | ||
case Vault.ExportSnapshot: | ||
console.log("snapshot exporting is done" | ||
, data.rc, data.snapshot, data.dst | ||
, data.stdout, data.stderr) | ||
break | ||
case Vault.ExportImportPrepare: | ||
break | ||
case Vault.ExportImportExecute: | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
|
||
function vaultData(operation, context) { | ||
switch (operation) { | ||
case Vault.SnapshotUnits: | ||
break | ||
case Vault.Snapshots: | ||
break | ||
case Vault.Units: | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
|
||
function vaultOperationProgress(operation, data) { | ||
switch (operation) { | ||
case Vault.Backup: | ||
break | ||
case Vault.Restore: | ||
break | ||
case Vault.ExportImportExecute: | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
|
||
function vaultOperationError(operation, error) { | ||
console.log("vault operation", operation, "error") | ||
switch (operation) { | ||
case Vault.Connect: | ||
break | ||
case Vault.Backup: | ||
break | ||
case Vault.Restore: | ||
break | ||
case Vault.RemoveSnapshot: | ||
break | ||
case Vault.ExportImportPrepare: | ||
break | ||
case Vault.ExportImportExecute: | ||
break | ||
case Vault.ExportSnapshot: | ||
console.log("error exporting snapshot" | ||
, error.rc, error.snapshot, error.dst | ||
, error.stdout, error.stderr) | ||
default: | ||
break | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
trace () { | ||
echo "`basename $0`: ${@:1}" 1>&2; | ||
} | ||
|
||
error() { | ||
trace $@ | ||
exit 1 | ||
} | ||
|
||
[ $# -eq 2 ] || error "Usage: $0 snapshot dst_dir" | ||
|
||
SNAP=$1 | ||
DST=$2 | ||
|
||
if [ "${SNAP:0:1}" != ">" ]; then | ||
SNAP=">$SNAP" | ||
fi | ||
|
||
git rev-parse --show-toplevel || error "Not a git dir $(pwd)" | ||
git rev-parse "$SNAP" >/dev/null || error "There is no snapshot $SNAP" | ||
[ -d $DST ] || error "There is no destination dir $DST" | ||
|
||
# only $DST itself is expected | ||
COUNT=$(find $DST -maxdepth 1 -not -name '.' | wc -l) | ||
if [ "x$COUNT" != "x1" ]; then | ||
error "Dst dir $DST should be empty, found $COUNT entries" | ||
fi | ||
|
||
trace "Export $SNAP to the $DST" | ||
|
||
GIT_DIR=$(pwd) | ||
(git archive --format=tar "$SNAP" | tar -C $DST -xf -) || \ | ||
error "Export of $SNAP to the $DST is failed" | ||
|
||
find $DST -type l | grep '/blobs/' | while read -r LINK | ||
do | ||
NAME=$(readlink $LINK) | ||
# match minimal relative blob ref (path inside the tree is unit/blobs/link) | ||
if [[ $NAME =~ \.\./\.\./\.git/blobs/ ]]; then | ||
FNAME=$(basename $NAME) | ||
DNAME="$GIT_DIR/.git/blobs/$(basename $(dirname $NAME))" | ||
[ -d $DNAME ] || error "There is no blob dir $DNAME for $LINK" | ||
FNAME="$DNAME/$FNAME" | ||
[ -f $FNAME ] || error "There is no blob file $FNAME for $LINK" | ||
unlink $LINK || error "Can't unlink $LINK" | ||
cp $FNAME $LINK || error "Can't copy $FNAME to $LINK" | ||
fi | ||
done |