[PR #13352] cmd: preserve relative paths for files and adapters in CreateHandler #76469

Open
opened 2026-05-05 09:02:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13352
Author: @unbiasedcodex
Created: 12/6/2025
Status: 🔄 Open

Base: mainHead: fix/windows-path-handling


📝 Commits (1)

  • c98848f cmd: preserve relative paths for files and adapters in CreateHandler

📊 Changes

1 file changed (+2 additions, -6 deletions)

View changed files

📝 cmd/cmd.go (+2 -6)

📄 Description

Summary:

  • Fixes file path handling in CreateHandler that was incorrectly using filepath.Base()
  • This caused files in subdirectories with the same name to overwrite each other in the map
  • Removes the TODO comments that documented this known issue

Problem:

When creating a model with files in different subdirectories that have the same filename:

MODEL models/lora/adapter.safetensors
MODEL models/lora2/adapter.safetensors

The second entry would overwrite the first because filepath.Base() stripped the directory path, leaving only adapter.safetensors as the key for both.

Solution:

Preserve the full relative path instead of extracting just the filename.
The server already expects and validates relative paths via fs.ValidPath().

Fixes #10333


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13352 **Author:** [@unbiasedcodex](https://github.com/unbiasedcodex) **Created:** 12/6/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/windows-path-handling` --- ### 📝 Commits (1) - [`c98848f`](https://github.com/ollama/ollama/commit/c98848f1f82c7d1d144fdf1970e34268ca337823) cmd: preserve relative paths for files and adapters in CreateHandler ### 📊 Changes **1 file changed** (+2 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+2 -6) </details> ### 📄 Description Summary: - Fixes file path handling in `CreateHandler` that was incorrectly using `filepath.Base()` - This caused files in subdirectories with the same name to overwrite each other in the map - Removes the TODO comments that documented this known issue Problem: When creating a model with files in different subdirectories that have the same filename: MODEL models/lora/adapter.safetensors MODEL models/lora2/adapter.safetensors The second entry would overwrite the first because `filepath.Base()` stripped the directory path, leaving only `adapter.safetensors` as the key for both. Solution: Preserve the full relative path instead of extracting just the filename. The server already expects and validates relative paths via `fs.ValidPath()`. Fixes #10333 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:02:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76469