Romern / syncMyMoodle

Synchronization client for RWTH Moodle
GNU General Public License v3.0
73 stars 18 forks source link

Handle files with the same filename #35

Open Romern opened 3 years ago

Romern commented 3 years ago

In 1 run, keep track if any files have the same name.

Romern commented 3 years ago

Possibly fixed in https://github.com/Romern/syncMyMoodle/commit/ea17a29d741d5fca17f6175aeef5305bf4ce482e

kingelilol commented 1 year ago

I just ran into this issue myself. There are two pdfs called "main.pdf" in one moodle folder. This results for me in "main_NmFkZjk3Zj.pdf" containing one of both pdfs. That should be the interesting part of the log.... I hope.

{
  "id": 281424,
  "name": "Mandatory Tutorial 1",
  "visible": 1,
  "summary": "<p dir=\"ltr\" style=\"text-align: left;\">Time: Tuesday, 18.04.2023, 14:00h<br>in Lecture Hall 4G, IKS</p><p dir=\"ltr\" style=\"text-align: left;\"><strong>Bring your PC to IKS.</strong><br></p><p dir=\"ltr\" style=\"text-align: left;\"><strong>Homework:</strong><br>as preparation for the experiment, read the theory in Chapters 1 and 2 and install the development environment on your PC.&nbsp;<span style=\"font-size: 0.9375rem;\">Also think of projects you would like to work on.</span></p>",
  "summaryformat": 1,
  "section": 2,
  "hiddenbynumsections": 0,
  "uservisible": true,
  "modules": [
    {
      "id": 1244285,
      "url": "https://moodle.rwth-aachen.de/mod/resource/view.php?id=1244285",
      "name": "Installation of Development Environment",
      "instance": 574235,
      "contextid": 2930256,
      "visible": 1,
      "uservisible": true,
      "visibleoncoursepage": 1,
      "modicon": "https://moodle.rwth-aachen.de/theme/image.php/boost_union_rwth/resource/1680152925/monologo",
      "modname": "resource",
      "modplural": "Dateien",
      "indent": 0,
      "onclick": "",
      "afterlink": " <span class=\"resourcelinkdetails\">1.1 MB Geändert 4.04.2023 11:38</span>",
      "customdata": "{\"displayoptions\":\"a:4:{s:10:\\\"printintro\\\";i:1;s:8:\\\"showsize\\\";i:1;s:8:\\\"showdate\\\";i:1;s:11:\\\"filedetails\\\";a:2:{s:4:\\\"size\\\";i:1140014;s:12:\\\"modifieddate\\\";s:10:\\\"1680601086\\\";}}\",\"display\":5}",
      "noviewlink": false,
      "completion": 1,
      "completiondata": {
        "state": 1,
        "timecompleted": 1681222860,
        "overrideby": null,
        "valueused": false,
        "hascompletion": true,
        "isautomatic": false,
        "istrackeduser": true,
        "uservisible": true,
        "details": []
      },
      "downloadcontent": 1,
      "dates": [],
      "contents": [
        {
          "type": "file",
          "filename": "main.pdf",
          "filepath": "/",
          "filesize": 1140014,
          "fileurl": "https://moodle.rwth-aachen.de/webservice/pluginfile.php/2930256/mod_resource/content/2/main.pdf?forcedownload=1",
          "timecreated": 1680184011,
          "timemodified": 1680601086,
          "sortorder": 1,
          "mimetype": "application/pdf",
          "isexternalfile": false,
          "userid": 94384,
          "author": "redacted",
          "license": "allrightsreserved"
        }
      ],
      "contentsinfo": {
        "filescount": 1,
        "filessize": 1140014,
        "lastmodified": 1680601086,
        "mimetypes": [
          "application/pdf"
        ],
        "repositorytype": ""
      }
    },
    {
      "id": 1244288,
      "url": "https://moodle.rwth-aachen.de/mod/resource/view.php?id=1244288",
      "name": "Tutorial 1 - Real-Time Audio Processing with MATLAB",
      "instance": 574238,
      "contextid": 2930259,
      "visible": 1,
      "uservisible": true,
      "visibleoncoursepage": 1,
      "modicon": "https://moodle.rwth-aachen.de/theme/image.php/boost_union_rwth/resource/1680152925/monologo",
      "modname": "resource",
      "modplural": "Dateien",
      "indent": 0,
      "onclick": "",
      "afterlink": " <span class=\"resourcelinkdetails\">1.5 MB Geändert 4.04.2023 09:59</span>",
      "customdata": "{\"displayoptions\":\"a:4:{s:10:\\\"printintro\\\";i:1;s:8:\\\"showsize\\\";i:1;s:8:\\\"showdate\\\";i:1;s:11:\\\"filedetails\\\";a:2:{s:4:\\\"size\\\";i:1620687;s:12:\\\"modifieddate\\\";s:10:\\\"1680595186\\\";}}\",\"display\":5}",
      "noviewlink": false,
      "completion": 1,
      "completiondata": {
        "state": 0,
        "timecompleted": 0,
        "overrideby": null,
        "valueused": false,
        "hascompletion": true,
        "isautomatic": false,
        "istrackeduser": true,
        "uservisible": true,
        "details": []
      },
      "downloadcontent": 1,
      "dates": [],
      "contents": [
        {
          "type": "file",
          "filename": "main.pdf",
          "filepath": "/",
          "filesize": 1620687,
          "fileurl": "https://moodle.rwth-aachen.de/webservice/pluginfile.php/2930259/mod_resource/content/3/main.pdf?forcedownload=1",
          "timecreated": 1680187995,
          "timemodified": 1680595186,
          "sortorder": 1,
          "mimetype": "application/pdf",
          "isexternalfile": false,
          "userid": 94384,
          "author": "redacted",
          "license": "allrightsreserved"
        }
      ],
      "contentsinfo": {
        "filescount": 1,
        "filessize": 1620687,
        "lastmodified": 1680595186,
        "mimetypes": [
          "application/pdf"
        ],
        "repositorytype": ""
      }
    }
  ]
}

Both versions the master and the one installed via pip run into this issue. ea17a29 seams to old as it directly crashes while logging it. An easy solution might be to always use the display name for the file.