Skip to content

Commit

Permalink
Modified progress_update().
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayasy committed Jul 31, 2021
1 parent 1e9f8a5 commit 6a73ff2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ So for this to work, you must be able to login to the sync-host with [OpenSSH].
This work is required for each sync-host include local-host.
1. Do the following to build and install.
```
curl -LOJs https://github.com/kobayasy/pSync/releases/download/2.12/psync-2.12.tar.gz
tar xzf psync-2.12.tar.gz
cd psync-2.12
curl -LOJs https://github.com/kobayasy/pSync/releases/download/2.13/psync-2.13.tar.gz
tar xzf psync-2.13.tar.gz
cd psync-2.13
./configure --prefix=$HOME
make install
```
Expand Down
6 changes: 3 additions & 3 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
ローカルホストを含めた全ての同期ホストに対してこの作業が必要です。
1. 以下の手順でビルドとインストールを行ないます。
```
curl -LOJs https://github.com/kobayasy/pSync/releases/download/2.12/psync-2.12.tar.gz
tar xzf psync-2.12.tar.gz
cd psync-2.12
curl -LOJs https://github.com/kobayasy/pSync/releases/download/2.13/psync-2.13.tar.gz
tar xzf psync-2.13.tar.gz
cd psync-2.13
./configure --prefix=$HOME
make install
```
Expand Down
4 changes: 2 additions & 2 deletions src/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Installation:
This work is required for each sync-host include local-host.
1. Do the following to build and install.
---
tar xzf psync-2.12.tar.gz
cd psync-2.12
tar xzf psync-2.13.tar.gz
cd psync-2.13
./configure --prefix=$HOME
make install
---
Expand Down
18 changes: 9 additions & 9 deletions src/configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for pSync 2.12.
# Generated by GNU Autoconf 2.69 for pSync 2.13.
#
# Report bugs to <kobayasy@kobayasy.com>.
#
Expand Down Expand Up @@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='pSync'
PACKAGE_TARNAME='psync'
PACKAGE_VERSION='2.12'
PACKAGE_STRING='pSync 2.12'
PACKAGE_VERSION='2.13'
PACKAGE_STRING='pSync 2.13'
PACKAGE_BUGREPORT='kobayasy@kobayasy.com'
PACKAGE_URL='http://kobayasy.com/psync/'

Expand Down Expand Up @@ -1242,7 +1242,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures pSync 2.12 to adapt to many kinds of systems.
\`configure' configures pSync 2.13 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1307,7 +1307,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of pSync 2.12:";;
short | recursive ) echo "Configuration of pSync 2.13:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1394,7 +1394,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
pSync configure 2.12
pSync configure 2.13
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1763,7 +1763,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by pSync $as_me 2.12, which was
It was created by pSync $as_me 2.13, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -4760,7 +4760,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by pSync $as_me 2.12, which was
This file was extended by pSync $as_me 2.13, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -4823,7 +4823,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
pSync config.status 2.12
pSync config.status 2.13
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
16 changes: 6 additions & 10 deletions src/configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# configure.ac - Last modified: 18-Jul-2021 (kobayasy)
# configure.ac - Last modified: 31-Jul-2021 (kobayasy)
#
# Copyright (c) 2018-2021 by Yuichi Kobayashi <kobayasy@kobayasy.com>
#
Expand All @@ -23,7 +23,7 @@
# SOFTWARE.

AC_PREREQ(2.69)
AC_INIT([pSync], [2.12], [kobayasy@kobayasy.com], [psync], [http://kobayasy.com/psync/])
AC_INIT([pSync], [2.13], [kobayasy@kobayasy.com], [psync], [http://kobayasy.com/psync/])
AC_CONFIG_SRCDIR([psync.c])
AC_CONFIG_AUX_DIR([conf])

Expand All @@ -33,14 +33,10 @@ AC_PROG_INSTALL

AC_SYS_LARGEFILE
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC"])
AC_CHECK_FUNC([clock_gettime],
[],
[AC_CHECK_LIB([rt], [clock_gettime])] )
AC_CHECK_HEADERS([termcap.h],
[AC_CHECK_FUNC([tgetent],
[AC_DEFINE([HAVE_TGETENT], [1], [Define to 1 if you have the tgetent() function.])],
[AC_SEARCH_LIBS([tgetent], [tinfo ncurses],
[AC_DEFINE([HAVE_TGETENT], [1])] )] )] )
AC_CHECK_FUNC([clock_gettime], [], [AC_CHECK_LIB([rt], [clock_gettime])])
AC_CHECK_HEADERS([termcap.h], [AC_CHECK_FUNC([tgetent],
[AC_DEFINE([HAVE_TGETENT], [1], [Define to 1 if you have the tgetent() function.])],
[AC_SEARCH_LIBS([tgetent], [tinfo ncurses], [AC_DEFINE([HAVE_TGETENT], [1])])] )])

AC_CONFIG_HEADERS([config.h])
AH_TOP([#ifndef _INCLUDE_config_h
Expand Down
16 changes: 7 additions & 9 deletions src/psync.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* psync.c - Last modified: 01-Jul-2021 (kobayasy)
/* psync.c - Last modified: 31-Jul-2021 (kobayasy)
*
* Copyright (c) 2018-2021 by Yuichi Kobayashi <kobayasy@kobayasy.com>
*
Expand Down Expand Up @@ -172,7 +172,7 @@ static int progress_update(PROGRESS *progress, intmax_t update) {
struct timespec now;

if (progress->fd != -1) {
progress->update = update;
progress->update += update;
if (progress->update != progress->data) {
if (clock_gettime(CLOCK_REALTIME, &now) == -1)
goto error;
Expand Down Expand Up @@ -777,7 +777,6 @@ static int make_fsynced_get_func(SETS sets, FLIST *flocal, FLIST *fremote, void

static int preload(PRIV *priv) {
int status = INT_MIN;
intmax_t uploadsize;
PROGRESS progress;
char pathname[PATH_MAX], *name;
char loadname[PATH_MAX], *p;
Expand All @@ -786,7 +785,7 @@ static int preload(PRIV *priv) {
char buffer[SYMLINK_MAX];

ONSTOP(priv->stop, ERROR_STOP);
progress_init(&progress, priv->info, PROGRESS_INTERVAL, "U%+jd\n", uploadsize = 0);
progress_init(&progress, priv->info, PROGRESS_INTERVAL, "U%+jd\n", 0);
name = pathname, name += sprintf(name, "%s/", priv->dirname);
p = loadname, p += sprintf(p, "%s/"SYNCDIR"/"LOCKDIR"/", priv->dirname);
count = 0;
Expand Down Expand Up @@ -820,7 +819,7 @@ static int preload(PRIV *priv) {
switch (fsynced->st.flags & (FST_DNLD|FST_RTYPE)) {
case FST_DNLD|FST_RREG:
case FST_DNLD|FST_RLNK:
progress_update(&progress, uploadsize += fsynced->st.size);
progress_update(&progress, fsynced->st.size);
break;
}
}
Expand Down Expand Up @@ -899,7 +898,6 @@ static int upload(PRIV *priv) {

static int download(PRIV *priv) {
int status = INT_MIN;
intmax_t downloadsize;
PROGRESS progress;
char loadname[PATH_MAX], *p;
unsigned long count;
Expand All @@ -911,7 +909,7 @@ static int download(PRIV *priv) {
struct timeval tv[2];

ONSTOP(priv->stop, ERROR_STOP);
progress_init(&progress, priv->info, PROGRESS_INTERVAL, "D%+jd\n", downloadsize = 0);
progress_init(&progress, priv->info, PROGRESS_INTERVAL, "D%+jd\n", 0);
p = loadname, p += sprintf(p, "%s/"SYNCDIR"/"LOCKDIR"/", priv->dirname);
count = 0;
for (fsynced = priv->fsynced.next; *fsynced->name; fsynced = fsynced->next) {
Expand Down Expand Up @@ -940,7 +938,7 @@ static int download(PRIV *priv) {
goto error;
}
size -= n;
progress_update(&progress, downloadsize += n);
progress_update(&progress, n);
}
close(fd), fd = -1;
if (chmod(loadname, fsynced->st.mode & (S_IRWXU|S_IRWXG|S_IRWXO)) == -1) {
Expand All @@ -962,7 +960,7 @@ static int download(PRIV *priv) {
status = ERROR_FWRITE;
goto error;
}
progress_update(&progress, downloadsize += size);
progress_update(&progress, size);
break;
}
tv[0].tv_sec = fsynced->st.mtime, tv[0].tv_usec = 0;
Expand Down

0 comments on commit 6a73ff2

Please sign in to comment.