domingo, febrero 18, 2018

odrive–unlimited file size

DIY

Considering the fact that we are creating a brand new system to facilitate unlimited file sizes and universal upload resume capabilities, it is important to us that this system be completely transparent, and independent of odrive. To demonstrate this, we created some simple shell scripts that anyone can use to re-assemble the raw odrive IFS file packages.

Powershell:

#Run inside the parent of the downloaded .xlarge directory
$xl_dir_name = "[name of xlarge directory]"
$xl_name = $xl_dir_name.Substring(0,$xl_dir_name.Length-40)
$meta_path = "$xl_dir_name\.meta"
$segments = Select-String -pattern "CLOUD-XL-SEGMENTS" $meta_path -List
$num_segments = $segments.line.split(":")[1]
echo "Assembling $xl_name...."
rm "$xl_name" -erroraction 'silentlycontinue'
ni "$xl_name" -type file | Out-Null
for ($i=0; $i -lt $num_segments; $i++) {
$cur_seg = Select-String -pattern "CLOUD-XL-SEGMENT:$i" $meta_path -context 0,2 -List
$filename = $cur_seg.context.DisplayPostContext[1].split(":")[1]
echo "adding segment: $filename to $xl_name"
$copy_output = $(cmd /q /c copy /b "$xl_name" + "$xl_dir_name\$filename" "$xl_name")
}

Bash:

#Run inside the parent of the downloaded .xlarge directory
xl_dir_name="[name of xlarge directory]"
xl_name="${xl_dir_name::${#xl_dir_name}-40}"
meta_path="$xl_dir_name/.meta"
num_seg_str=$(grep "CLOUD-XL-SEGMENTS:" $meta_path)
num_seg_str_split=(${num_seg_str//:/ })
num_segs=${num_seg_str_split[1]}
for (( i=0; i<$num_segs; i++)) do
cur_seg_str=$(grep -A 2 "CLOUD-XL-SEGMENT:$i" $meta_path | grep "CLOUD-XL-SEGMENT-HASH")
cur_seg_str_split=(${cur_seg_str//:/ })
filename=${cur_seg_str_split[1]}
echo "adding $xl_dir_name/$filename to $xl_name"
cat "$xl_dir_name/$filename" >> "$xl_name"
done

No hay comentarios.: