Changeset 14317


Ignore:
Timestamp:
Jul 4, 2014, 3:23:27 AM (8 years ago)
Author:
jordan
Message:

(trunk, libT) #5656 'Problems renaming files' -- fixed, patch by rb07

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rename-test.c

    r14289 r14317  
    369369    {
    370370      check_streq (expected_files[i], files[i].name);
    371       check (testFileExistsAndConsistsOfThisString (tor, 1, expected_contents[1]));
     371      check (testFileExistsAndConsistsOfThisString (tor, i, expected_contents[i]));
    372372    }
    373373  check (files[0].is_renamed == false);
     
    440440    }
    441441
     442  /**
     443  ***  Test renaming prefixes (shouldn't work)
     444  **/
     445
     446  tr_torrentRemove (tor, false, NULL);
     447  do {
     448    tr_wait_msec (10);
     449  } while (0);
     450  ctor = tr_ctorNew (session);
     451  tor = create_torrent_from_base64_metainfo (ctor,
     452    "ZDEwOmNyZWF0ZWQgYnkyNTpUcmFuc21pc3Npb24vMi42MSAoMTM0MDcpMTM6Y3JlYXRpb24gZGF0"
     453    "ZWkxMzU4NTU1NDIwZTg6ZW5jb2Rpbmc1OlVURi04NDppbmZvZDU6ZmlsZXNsZDY6bGVuZ3RoaTI4"
     454    "ZTQ6cGF0aGw3OkZlbGluYWU4OkFjaW5vbnl4NzpDaGVldGFoNzpDaGVzdGVyZWVkNjpsZW5ndGhp"
     455    "MTJlNDpwYXRobDc6RmVsaW5hZTU6RmVsaXM1OmNhdHVzNTpLeXBoaWVlZDY6bGVuZ3RoaTZlNDpw"
     456    "YXRobDc6RmVsaW5hZTU6RmVsaXM1OmNhdHVzNzpTYWZmcm9uZWVkNjpsZW5ndGhpMjFlNDpwYXRo"
     457    "bDExOlBhbnRoZXJpbmFlODpQYW50aGVyYTU6VGlnZXI0OlRvbnllZWU0Om5hbWU3OkZlbGlkYWUx"
     458    "MjpwaWVjZSBsZW5ndGhpMzI3NjhlNjpwaWVjZXMyMDp27buFkmy8ICfNX4nsJmt0Ckm2Ljc6cHJp"
     459    "dmF0ZWkwZWVl");
     460  check (tr_isTorrent (tor));
     461  files = tor->info.files;
     462
     463  /* rename prefix of top */
     464  check_int_eq (EINVAL, torrentRenameAndWait (tor, "Feli", "FelidaeX"));
     465  check_streq (tor->info.name, "Felidae");
     466  check (files[0].is_renamed == false);
     467  check (files[1].is_renamed == false);
     468  check (files[2].is_renamed == false);
     469  check (files[3].is_renamed == false);
     470
     471  /* rename false path */
     472  check_int_eq (EINVAL, torrentRenameAndWait (tor, "Felidae/FelinaeX", "Genus Felinae"));
     473  check_streq (tor->info.name, "Felidae");
     474  check (files[0].is_renamed == false);
     475  check (files[1].is_renamed == false);
     476  check (files[2].is_renamed == false);
     477  check (files[3].is_renamed == false);
     478
    442479  /***
    443480  ****
  • trunk/libtransmission/torrent.c

    r14316 r14317  
    35933593      const char * name = tor->info.files[i].name;
    35943594      const size_t len = strlen (name);
    3595       if ((len >= oldpath_len) && !memcmp (oldpath, name, oldpath_len))
     3595      if ((len == oldpath_len || (len > oldpath_len && name[oldpath_len] == '/')) &&
     3596          !memcmp (oldpath, name, oldpath_len))
    35963597        indices[n++] = i;
    35973598    }
     
    37363737      if (n == 0)
    37373738        {
    3738           errno = EINVAL;
     3739          error = EINVAL;
    37393740        }
    37403741      else
Note: See TracChangeset for help on using the changeset viewer.