From 8c4d44189d80e35ef0b1cd1a30387f0e3a852060 Mon Sep 17 00:00:00 2001 From: Katie Holly Date: Tue, 12 Mar 2019 06:24:47 +0100 Subject: [PATCH 1/2] use uuids instead of %Y%m%d%H%M%S stamps --- chunker | 6 +++--- pack-one | 4 ++-- upload-one | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chunker b/chunker index 8872018..fa7d02e 100755 --- a/chunker +++ b/chunker @@ -48,9 +48,9 @@ do # rename it to archive-XXXXX and start a new current/ if [[ $cur_size -gt $BYTES_PER_CHUNK ]] then - timestamp=$( date +'%Y%m%d%H%M%S' ) - echo "Current archive is full, moving to ${timestamp}." - mv "$CHUNKER_WORKING_DIR/current" "$PACKING_QUEUE_DIR/${timestamp}" + uuid=$(cat /proc/sys/kernel/random/uuid) + echo "Current archive is full, moving to ${uuid}." + mv "$CHUNKER_WORKING_DIR/current" "$PACKING_QUEUE_DIR/${uuid}" cur_size=0 sleep 3 fi diff --git a/pack-one b/pack-one index 63d40e7..e6968ba 100755 --- a/pack-one +++ b/pack-one @@ -55,8 +55,8 @@ mayicontinue ITEM=none while [[ $ITEM = none ]] do - possible_item=$( ls -1 "$PACKING_QUEUE_DIR/" | grep 201 | sort | head -n 1 ) - if [[ $possible_item =~ 201 ]] + possible_item=$( ls -1 "$PACKING_QUEUE_DIR/" | grep -E '_[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$' | sort | head -n 1 ) + if test -n "${possible_item}" then echo "Trying to grab $possible_item" if mv "$PACKING_QUEUE_DIR/$possible_item" "$PACKER_WORKING_CHUNKS_DIR/" diff --git a/upload-one b/upload-one index aa3c2c4..a2847cc 100755 --- a/upload-one +++ b/upload-one @@ -40,8 +40,8 @@ mayicontinue ITEM=none while [[ $ITEM = none ]] do - possible_item=$( ls -1 "$UPLOAD_QUEUE_DIR" | grep 201 | sort | head -n 1 ) - if [[ $possible_item =~ 201 ]] + possible_item=$( ls -1 "$UPLOAD_QUEUE_DIR" | grep -E '_[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$' | sort | head -n 1 ) + if test -n "${possible_item}" then echo "Trying to grab $possible_item" if mv "$UPLOAD_QUEUE_DIR/$possible_item" "$UPLOADER_WORKING_DIR/" From f88d14b2a2ab4a2a1749e1f01d045245150cd3c1 Mon Sep 17 00:00:00 2001 From: Katie Holly Date: Tue, 12 Mar 2019 17:06:07 +0100 Subject: [PATCH 2/2] Use timestamp and first 8 characters of UUIDv4 hex --- chunker | 7 ++++--- pack-one | 2 +- upload-one | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/chunker b/chunker index fa7d02e..7075179 100755 --- a/chunker +++ b/chunker @@ -48,9 +48,10 @@ do # rename it to archive-XXXXX and start a new current/ if [[ $cur_size -gt $BYTES_PER_CHUNK ]] then - uuid=$(cat /proc/sys/kernel/random/uuid) - echo "Current archive is full, moving to ${uuid}." - mv "$CHUNKER_WORKING_DIR/current" "$PACKING_QUEUE_DIR/${uuid}" + timestamp=$( date +'%Y%m%d%H%M%S' ) + uuid=$(cat /proc/sys/kernel/random/uuid | cut -d- -f1) + echo "Current archive is full, moving to ${timestamp}_${uuid}." + mv "$CHUNKER_WORKING_DIR/current" "$PACKING_QUEUE_DIR/${timestamp}_${uuid}" cur_size=0 sleep 3 fi diff --git a/pack-one b/pack-one index e6968ba..b798e77 100755 --- a/pack-one +++ b/pack-one @@ -55,7 +55,7 @@ mayicontinue ITEM=none while [[ $ITEM = none ]] do - possible_item=$( ls -1 "$PACKING_QUEUE_DIR/" | grep -E '_[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$' | sort | head -n 1 ) + possible_item=$( ls -1 "$PACKING_QUEUE_DIR/" | grep -E '[0-9]{14}_[a-f0-9]{8}$' | sort | head -n 1 ) if test -n "${possible_item}" then echo "Trying to grab $possible_item" diff --git a/upload-one b/upload-one index a2847cc..b8f867c 100755 --- a/upload-one +++ b/upload-one @@ -40,7 +40,7 @@ mayicontinue ITEM=none while [[ $ITEM = none ]] do - possible_item=$( ls -1 "$UPLOAD_QUEUE_DIR" | grep -E '_[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$' | sort | head -n 1 ) + possible_item=$( ls -1 "$UPLOAD_QUEUE_DIR" | grep -E '[0-9]{14}_[a-f0-9]{8}$' | sort | head -n 1 ) if test -n "${possible_item}" then echo "Trying to grab $possible_item"