Mercurial > gftp.yaz
comparison lib/protocols.c @ 381:1c86bcb0b232
2003-2-1 Brian Masney <masneyb@gftp.org>
* lib/protocols.c (gftp_get_dir_listing, gftp_get_all_subdirs) - don't
modify the file variable if it begins with a /. Do not touch the
destfile variable if it already exists
author | masneyb |
---|---|
date | Sun, 01 Feb 2004 22:14:15 +0000 |
parents | 14da115b149b |
children | 14ef37b62c20 |
comparison
equal
deleted
inserted
replaced
380:05ee37a5558b | 381:1c86bcb0b232 |
---|---|
1746 | 1746 |
1747 if (dirhash && | 1747 if (dirhash && |
1748 (newsize = g_hash_table_lookup (dirhash, fle->file)) != NULL) | 1748 (newsize = g_hash_table_lookup (dirhash, fle->file)) != NULL) |
1749 fle->startsize = *newsize; | 1749 fle->startsize = *newsize; |
1750 | 1750 |
1751 if (transfer->toreq) | 1751 if (transfer->toreq && fle->destfile == NULL) |
1752 fle->destfile = gftp_build_path (transfer->toreq->directory, | 1752 fle->destfile = gftp_build_path (transfer->toreq->directory, |
1753 fle->file, NULL); | 1753 fle->file, NULL); |
1754 | 1754 |
1755 newname = gftp_build_path (transfer->fromreq->directory, | 1755 if (transfer->fromreq->directory != NULL && |
1756 fle->file, NULL); | 1756 *transfer->fromreq->directory != '\0' && |
1757 | 1757 *fle->file != '/') |
1758 g_free (fle->file); | 1758 { |
1759 fle->file = newname; | 1759 newname = gftp_build_path (transfer->fromreq->directory, |
1760 fle->file, NULL); | |
1761 | |
1762 g_free (fle->file); | |
1763 fle->file = newname; | |
1764 } | |
1760 | 1765 |
1761 templist = g_list_append (templist, fle); | 1766 templist = g_list_append (templist, fle); |
1762 | 1767 |
1763 fle = g_malloc (sizeof (*fle)); | 1768 fle = g_malloc (sizeof (*fle)); |
1764 } | 1769 } |
1777 | 1782 |
1778 int | 1783 int |
1779 gftp_get_all_subdirs (gftp_transfer * transfer, | 1784 gftp_get_all_subdirs (gftp_transfer * transfer, |
1780 void (*update_func) (gftp_transfer * transfer)) | 1785 void (*update_func) (gftp_transfer * transfer)) |
1781 { | 1786 { |
1782 char *oldfromdir, *oldtodir, *newname; | 1787 char *oldfromdir, *oldtodir, *newname, *pos; |
1783 GList * templist, * lastlist; | 1788 GList * templist, * lastlist; |
1784 int forcecd, remotechanged; | 1789 int forcecd, remotechanged; |
1785 unsigned long *newsize; | 1790 unsigned long *newsize; |
1786 GHashTable * dirhash; | 1791 GHashTable * dirhash; |
1787 gftp_file * curfle; | 1792 gftp_file * curfle; |
1796 dirhash = NULL; | 1801 dirhash = NULL; |
1797 | 1802 |
1798 for (lastlist = transfer->files; ; lastlist = lastlist->next) | 1803 for (lastlist = transfer->files; ; lastlist = lastlist->next) |
1799 { | 1804 { |
1800 curfle = lastlist->data; | 1805 curfle = lastlist->data; |
1801 if (dirhash && | 1806 |
1802 (newsize = g_hash_table_lookup (dirhash, curfle->file)) != NULL) | 1807 if ((pos = strrchr (curfle->file, '/')) != NULL) |
1808 pos++; | |
1809 else | |
1810 pos = curfle->file; | |
1811 | |
1812 if (dirhash != NULL && | |
1813 (newsize = g_hash_table_lookup (dirhash, pos)) != NULL) | |
1803 curfle->startsize = *newsize; | 1814 curfle->startsize = *newsize; |
1804 | 1815 |
1805 if (transfer->toreq) | 1816 if (curfle->size < 0 && GFTP_IS_CONNECTED (transfer->fromreq)) |
1806 curfle->destfile = g_strconcat (transfer->toreq->directory, "/", | 1817 curfle->size = gftp_get_file_size (transfer->fromreq, curfle->file); |
1807 curfle->file, NULL); | 1818 |
1808 newname = g_strconcat (transfer->fromreq->directory, transfer->fromreq->directory[strlen (transfer->fromreq->directory) - 1] == '/' ? "" : "/", curfle->file, NULL); | 1819 if (transfer->toreq && curfle->destfile == NULL) |
1809 g_free (curfle->file); | 1820 curfle->destfile = gftp_build_path (transfer->toreq->directory, |
1810 curfle->file = newname; | 1821 curfle->file, NULL); |
1822 | |
1823 if (transfer->fromreq->directory != NULL && | |
1824 *transfer->fromreq->directory != '\0' && | |
1825 *curfle->file != '/') | |
1826 { | |
1827 newname = gftp_build_path (transfer->fromreq->directory, | |
1828 curfle->file, NULL); | |
1829 g_free (curfle->file); | |
1830 curfle->file = newname; | |
1831 } | |
1811 | 1832 |
1812 if (lastlist->next == NULL) | 1833 if (lastlist->next == NULL) |
1813 break; | 1834 break; |
1814 } | 1835 } |
1815 | 1836 |