Changeset 924


Ignore:
Timestamp:
08/14/13 16:11:16 (11 years ago)
Author:
sdipsl
Message:

Enhance IGCM_debug_sizeOfTabContent prior to further work on #140

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh

    r917 r924  
    8686#D-function IGCM_debug_sizeOfTabContent 
    8787#D- * Purpose: Give sumed size of a list of files 
     88#D- * Usage: IGCM_debug_sizeOfTabContent entityList destination 
     89#D- *        where entityList is a list of files or directory 
     90#D- *        where dest is either a directory or a file name 
    8891function IGCM_debug_sizeOfTabContent 
    8992{ 
    90   typeset dm_liste ifile sizeFile sizeKo sizeMo 
    91   eval set +A dm_liste \${${1}} 
    92   sizeKo=0 
    93   for ((i = 0; i < ${#dm_liste[*]}; i += 1)) ; do 
    94     # echo "dm_liste[$i]=${dm_liste[$i]}" 
    95     # we want to compute the size from local path (not from archive ...) 
    96     # remove path /home/login/../ from dm_liste elements 
    97     if [ -f ${dm_liste[$i]##/*/} ] ; then 
    98       ifile=${dm_liste[$i]##/*/} 
    99     elif [ -f ${2} ] ; then 
    100       ifile=${2} 
    101     elif [ -f $2/${dm_liste[$i]##/*/} ] ; then 
    102       ifile=${2}/${dm_liste[$i]##/*/} 
    103     fi 
    104     sizeFile=$( du --apparent-size -k ${ifile} | awk {'print $1'} ) 
    105     sizeKo=$(( $sizeKo + $sizeFile )) 
     93  typeset entityListe destination iEntity sizeKo sumSizeKo sumSizeMo 
     94 
     95  eval set +A entityListe \${${1}} 
     96  destination=${2}   
     97  sumSizeKo=0 
     98 
     99  # Here we will try to compute size (file or directory size) from local path and not from archive. 
     100  for ((i = 0; i < ${#entityListe[*]}; i += 1)) ; do   
     101    if [ -f ${entityListe[$i]##/*/} ] ; then 
     102      # One file or a bunch of files has been copied without renaming 
     103      # remove path /home/login/../ from entityListe elements 
     104      iEntity=${entityListe[$i]##/*/} 
     105    elif [ -f ${destination} ] ; then 
     106      # a file has been copied and rename 
     107      iEntity=${destination} 
     108    elif [ -f ${destination}/${entityListe[$i]##/*/} ] ; then 
     109      # a copy in a directory but not in ${PWD} 
     110      iEntity=${destination}/${entityListe[$i]##/*/} 
     111    elif [ -d ${entityListe[$i]} ] ; then 
     112      # directory has been copied from non remote place 
     113      iEntity=${entityListe[$i]} 
     114    elif [ -d ${destination}/${entityListe[$i]##/*/} ] ; then 
     115      # directory has been copied from remote archive and not rename 
     116      iEntity=${destination}/${entityListe[$i]##/*/} 
     117    elif [ -d ${destination} ] ; then 
     118      # directory has been copied from remote archive and rename 
     119      iEntity=${destination} 
     120    fi 
     121    sizeKo=$( du --apparent-size -k ${iEntity} | awk {'print $1'} ) 
     122    sumSizeKo=$(( $sumSizeKo + $sizeKo )) 
    106123  done 
    107   sizeMo=$( echo "scale=6;${sizeKo}/1024" | bc ) 
    108   echo "${sizeKo}|${sizeMo}" 
     124  sumSizeMo=$( echo "scale=6;${sumSizeKo}/1024" | bc ) 
     125  echo "${sumSizeKo}|${sumSizeMo}" 
    109126} 
    110127 
     
    313330    # Classical copy (only files are given to IGCM_sys_Cp as options) 
    314331    IGCM_sys_Cp) 
    315       instrumentation=true       
     332      instrumentation=true 
    316333      # All but the latest 
    317334      fileList=${arguments[*]:0:${#arguments[*]}-1} 
     
    321338      dest=${arguments[${#arguments[*]}-1]} 
    322339      # Size of file whose name are stored in a list 
    323       entitySize=$( IGCM_debug_sizeOfTabContent fileList $dest ) 
     340      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} ) 
    324341      ;; 
    325342 
     
    327344    IGCM_sys_Get_Master|IGCM_sys_Get_Dir) 
    328345      instrumentation=true 
    329       if [ ${#arguments[*]} -eq 2 ] ; then 
    330         source=${arguments[0]} 
    331         dest=${arguments[1]} 
    332         # Size of file whose name are stored in a variable 
    333         entitySize=$( IGCM_debug_sizeOfTabContent source ) 
    334       fi 
     346      source=${arguments[0]} 
     347      dest=${arguments[1]} 
     348      # Size of file whose name are stored in a variable 
     349      entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} ) 
    335350      ;; 
    336351 
Note: See TracChangeset for help on using the changeset viewer.