Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip dropbox file based on size #179

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/usr/local/kobocloud/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ done < $UserConfig

recursiveUpdateFiles() {
for item in *; do
if [ "$item" = "*" ]; then
continue
fi
if [ -d "$item" ]; then
(cd -- "$item" && recursiveUpdateFiles)
elif grep -Fq "$item" "$Lib/filesList.log"; then
Expand Down
26 changes: 24 additions & 2 deletions src/usr/local/kobocloud/getDropboxAppFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ client_id="$1"
refresh_token="$2"
outDir="$3"

#load config
# load config
. $(dirname $0)/config.sh
token=`$CURL -k --silent https://api.dropbox.com/oauth2/token \
-d grant_type=refresh_token \
Expand All @@ -23,9 +23,31 @@ grep '".tag": "file"' | grep '"is_downloadable": true' |
while read item
do
outFileName=`echo $item | sed -e 's/.*"name": "\([^"]*\)", ".*/\1/'`
outFileName=`echo $outFileName | sed -e 's/\\u00e0/à/' -e 's/\\u00e0/â/' -e 's/\\u00e8/è/' -e 's/\\u00e9/é/' -e 's/\\u00f8/ø/' -e 's/\\u0153/œ/'`
outFileName=`echo $outFileName | sed -e 's/\\u00e0/à/' -e 's/\\u00e0/â/' -e 's/\\u00e8/è/' -e 's/\\u00e9/é/' -e 's/\\u00f8/ø/' -e 's/\\u0153/œ/' -e 's/\\u2014/—/'`
outFileSize=`echo $item | sed -e 's/.*"size": \([0-9]*\), ".*/\1/'`
existingFileSize=`stat -c %s "$outDir/$outFileName" 2>/dev/null`
if [ -z "$existingFileSize" ]; then
existingFileSize=0
fi
remotePath=`echo $item | sed 's/.*"id": "\([^"]*\)", ".*/\1/'`
localFile="$outDir/$outFileName"

echo "outFileName: $outFileName"
echo "outFileSize: $outFileSize"
echo "existingFileSize: $existingFileSize"

if [ "$existingFileSize" -gt "$outFileSize" ]; then
rm "$outDir/$outFileName"
fi
if [ "$existingFileSize" -eq "$outFileSize" ]; then
echo "File $outFileName is up to date"
if grep -q "^REMOVE_DELETED" $UserConfig; then
echo "$localFile" >> "$Lib/filesList.log"
echo "Appended $localFile to filesList"
fi
continue
fi

$KC_HOME/getRemoteFile.sh "https://content.dropboxapi.com/2/files/download" "$localFile" "$token" "$remotePath"
if [ $? -ne 0 ] ; then
echo "Having problems contacting Dropbox. Try again in a couple of minutes."
Expand Down
Loading