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

Don't re-upload files #33

Open
jsncrdnl opened this issue Feb 27, 2019 · 5 comments
Open

Don't re-upload files #33

jsncrdnl opened this issue Feb 27, 2019 · 5 comments

Comments

@jsncrdnl
Copy link

It looks like the tool is always re-uploading files even if they're already online.
It'd be great to keep a log of already uploaded files (paths) to avoid re-uploading it.

@pacoorozco
Copy link
Contributor

pacoorozco commented May 5, 2019

Hi @jsncrdnl

I'm using a shell script on top of gpup in order to keep into count which files has been already uploaded. You can see it here.

The script will upload images recursively using the folder name as album name. And storing in a file which folders has been uploaded. So the next time you use the script only new images will be uploaded.

NOTE: My folder names has an specific template name YYYYMMDD: Description - Something, the script is coded to remove the last part Something in order to create the album name. You can configure this at this line

All my pictures are under a parent folder /home/paco/Pictures and I only need to use my script as:

$ upload_to_Google_Photos.sh -d /home/paco/Pictures

@Flipo
Copy link

Flipo commented May 15, 2019

HI @pacoorozco

Thank you for that script. It works great. But I have one Problem. The scripts skips the entire folder when the folder is uploaded. Therefore new files inside an existing folder are skipped too. Is there a way to modify your script so that new files inside an existing folder are recognized and uploaded?

@pacoorozco
Copy link
Contributor

Hi @Flipo

The script is optimized to use gpup multiple uploads... for this reason it's working with folder granularity. It creates an album for every folder.

To track files uploads your should change several parts of the script to work file by file. There are many options, depending if you want to maintain folders as a albums or not.

It should look like this way

Maintaining folders as albums

  1. Remove lines 62-66
  2. Change uploadDirectory function
# Uploads a directory and creates a new album using `gpup`.
function uploadDirectory() {
	local _dir; _dir=${1:-}
	[[ -z "${_dir}" ]] && die -e 127 "No directory has been specified."
	local _albumName
	_albumName=$(basename "${_dir%-*}")

        find "${_dir}" -mindepth 1 -maxdepth 1 -type f -print0 |
	while IFS= read -r -d '' File; do
          info "Processing ${File}"

# Check if directory was previously uploaded. Skip it if it was.
      if keyIsInDatabase "${File}" "${uploadedFilesDatabase}"; then
        debug "    File was found in uploaded files database. Skipped!"
        continue
      fi

	local _ret; _ret=0
    debug "Command: ${GPUPBinary} --new-album \"${_albumName}\" \"${_File}\""
	if [[ "${dryRunFlag}" -eq "0" ]]; then
		${GPUPBinary} --new-album "${_albumName}" "${_File}"
		_ret=$?
	fi
    done

	return ${_ret}
}

@jamiew
Copy link

jamiew commented Oct 23, 2019

I've found the upgrade in @gchangchen's fork to work well for this too. Saves a list of MD5's to a ~/.gpupcache file and skips whenever files match => gchangchen@88e3f29

@pacoorozco
Copy link
Contributor

pacoorozco commented Oct 24, 2019

It's a different approach than gpup, but you can take a look to gphotos-uploader-cli

I'm using both 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants