zola icon indicating copy to clipboard operation
zola copied to clipboard

load_data doesn't work on windows when files are stored on a mapped network drive

Open rdtrimble opened this issue 2 years ago • 1 comments

On windows when running zola in a directory on a mapped network drive. I get an error when there is a shortcode that needs to use the load_data function. In my set up N is a network drive, C is the local drive. Despite the error code there is no apparent access issue to the file, it is not locked by another program. I think the issue is something to do with "Failed to canonicalize" but not sure how to investigate further.

Failure on network drive with load_data

N:\Misc\planner>zola build
Building site...
Failed to build the site
Error: Failed to render content of N:/Misc/planner/content/_index.md
Reason: Failed to render timetable shortcode
Reason: Failed to render 'shortcodes/timetable.html'
Reason: Function call 'load_data' failed
Reason: `load_data`: Failed to canonicalize N:\Misc\planner\timetable2021.csv: Access is denied. (os error 5)

Success on network drive after removing the load_data function

N:\Misc\planner>zola build
Building site...
Checking all internal links with anchors.
> Successfully checked 0 internal link(s) with anchors.
-> Creating 43 pages (0 orphan), 7 sections, and processing 0 images
Done in 1.1s.

Success on local C drive with load_data

C:\Users\me\local\Planner>zola build
Building site...
Checking all internal links with anchors.
> Successfully checked 0 internal link(s) with anchors.
-> Creating 43 pages (0 orphan), 7 sections, and processing 0 images
Done in 324ms.

The offending file

+++
title = "RDT Planner"
draft = false
sort_by = "weight"
+++

# 2020-2021

{{ timetable(file="timetable2021.csv") }}

The associated shortcode

{% set data = load_data(path=file) -%}
{% if data %}
<table class="timetable">
<thead>
{%- for header in data.headers -%}
<th>{{ header }}</th>
{% endfor -%}
</thead>
<tbody>
{%- for row in data.records -%}
  {% if loop.index % 2 == 1%}
    <tr>
                {%- for cell in row -%}
                                <td><a href="/{{ cell | trim | replace(from="/", to="") | safe}}/">{{ cell }}</a></td>
                {% endfor -%}
                </tr>   
  {% else %}
    <tr>
                {%- for cell in row -%}
                                <td>{{ cell }}</td>
                {% endfor -%}
                </tr>
  {% endif %}
 {% endfor -%}
</tbody>
</table>
{% else %}No data found.{% endif %}

rdtrimble avatar Nov 21 '21 19:11 rdtrimble

Funnily enough, I think we canonicalize to make it work well on Windows >_>

Keats avatar Nov 23 '21 08:11 Keats