#! /bin/bash
#  $Id: store.sh,v 1.7 2003/11/25 10:51:51 wicke Exp $

  datafile=`cut -d " " -f 1 $tagfile`
  base=`basename $datafile`

  echo Check_size $datafile ...
  check_size.py $datafile || failed=5

  if [ $failed -eq 0 ] ; then
    echo sam store --descrip=$datafile.metadata.py ...
    sam store --descrip=$datafile.metadata.py --source=./

    # Now check whether we have a location for that new file:
    echo sam locate $base    
    located=`sam locate $base`
    echo $located

    if [ "$located" != "[]" ]; then
      if [ ! "`echo $located | grep 'No such file' `" = "" ] ; then
       echo "ERROR: File is still UNKNOWN to sam."
       failed=7
      fi
    else
       echo "ERROR: File is known to sam but not located in sam."
       failed=8
    fi



    if [ $failed -eq 0 ] ; then
       echo "sam store complete"
    else
       echo "ERROR: sam store failed"
    fi
  else
    echo "ERROR: $datafile not stored"
  fi
#

