Review: Approve


Diff comments:

> === modified file 'lib/lp/services/librarianserver/storage.py'
> --- lib/lp/services/librarianserver/storage.py        2015-12-27 04:00:36 
> +0000
> +++ lib/lp/services/librarianserver/storage.py        2016-09-19 13:43:37 
> +0000
> @@ -37,6 +37,34 @@
>      ]
>  
>  
> +def fsync_path(path, dir=False):
> +    fd = os.open(path, os.O_RDONLY | (os.O_DIRECTORY if dir else 0))
> +    try:
> +        os.fsync(fd)
> +    finally:
> +        os.close(fd)
> +
> +
> +def makedirs_fsync(name, mode=0777):
> +    """makedirs_fsync(path [, mode=0777])
> +
> +    os.makedirs, but fsyncing on the way up to ensure durability.
> +    """
> +    head, tail = os.path.split(name)
> +    if not tail:
> +        head, tail = os.path.split(head)
> +    if head and tail and not os.path.exists(head):
> +        try:
> +            makedirs_fsync(head, mode)
> +        except OSError, e:

except OSError as e:

> +            if e.errno != errno.EEXIST:
> +                raise
> +        if tail == os.curdir:
> +            return
> +    os.mkdir(name, mode)
> +    fsync_path(head, dir=True)
> +
> +
>  class DigestMismatchError(Exception):
>      """The given digest doesn't match the SHA-1 digest of the file."""
>  


-- 
https://code.launchpad.net/~wgrant/launchpad/librarian-fsync/+merge/306099
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to