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

Retrying failed uploads and .maintenance file #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion git-ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import logging
import textwrap
import fnmatch
import socket

# Note about Tree.path/Blob.path: *real* Git trees and blobs don't
# actually provide path information, but the git-python bindings, as a
Expand Down Expand Up @@ -175,7 +176,9 @@ def main():
if oldtree.hexsha == tree.hexsha:
logging.info('Nothing to do!')
else:
ftp.storbinary('STOR .maintenance', cStringIO.StringIO('<?php $upgrading = time(); ?>'))
upload_diff(repo, oldtree, tree, ftp, [base], patterns)
ftp.delete('.maintenance')

ftp.storbinary('STOR git-rev.txt', cStringIO.StringIO(commit.hexsha))
ftp.quit()
Expand Down Expand Up @@ -457,7 +460,23 @@ def upload_blob(blob, ftp, quiet=False):
ftp.delete(blob.path)
except ftplib.error_perm:
pass
ftp.storbinary('STOR ' + blob.path, blob.data_stream)

attempts = 0

while True:
try:
ftp.storbinary('STOR ' + blob.path, blob.data_stream)
break
except socket.error, e:
attempts += 1
if attempts >= 3:
logging.warning('Failed to upload ' + blob.path)
raise
else:
logging.warning('Retrying ' + blob.path)



try:
ftp.voidcmd('SITE CHMOD ' + format_mode(blob.mode) + ' ' + blob.path)
except ftplib.error_perm:
Expand Down