Skip to content

Commit

Permalink
- minor code enhancements
Browse files Browse the repository at this point in the history
- sync regular file as well as directory
  • Loading branch information
tri1976 committed May 2, 2012
1 parent f46a0bd commit 0020fa8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tmpfs-sync/tmpfs-sync
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function sync() {
backup=$i-backup
tmp=$tmpfs/${i//\//_}
if [[ `readlink "$i"` = "$tmp" ]]; then
rsync -a --delete "$i/" "$backup/" && echo "$i synced"
[[ -d $i ]] && rsync -a --delete "$tmp/" "$backup/" || rsync "$tmp" "$backup"
[[ $? -eq 0 ]] && echo "$i synced"
else
echo -e "${red}Sync failed...$i is not in tmpfs $none"
fi
Expand All @@ -35,7 +36,7 @@ function stopsync(){
backup=$i-backup
tmp=$tmpfs/${i//\//_}
if [[ `readlink "$i"` = "$tmp" ]]; then
rm -f "$i"
rm -rf "$i"
[[ -e $backup ]] && mv "$backup" "$i"
[[ -e $tmp ]] && rm -rf "$tmp"
echo "$i stopped"
Expand Down

0 comments on commit 0020fa8

Please sign in to comment.