mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-21 14:26:30 +00:00
fix: select and update models folder in settings (#13412)
This commit is contained in:
@@ -169,37 +169,47 @@ DlgResult fileDlg(FileDlgParams* params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSArray* urls = [panel URLs];
|
NSArray* urls = [panel URLs];
|
||||||
if(self->params->allowMultiple && [urls count] >= 1) {
|
if([urls count] == 0) {
|
||||||
|
return DLG_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(self->params->allowMultiple) {
|
||||||
// For multiple files, we need to return all paths separated by null bytes
|
// For multiple files, we need to return all paths separated by null bytes
|
||||||
char* bufPtr = self->params->buf;
|
char* bufPtr = self->params->buf;
|
||||||
int remainingBuf = self->params->nbuf;
|
int remainingBuf = self->params->nbuf;
|
||||||
|
|
||||||
// Calculate total required buffer size first
|
// Calculate total required buffer size first
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
for(NSURL* url in urls) {
|
for(NSURL* url in urls) {
|
||||||
char tempBuf[PATH_MAX];
|
char tempBuf[PATH_MAX];
|
||||||
if(![url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX]) {
|
if(![url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX]) {
|
||||||
return DLG_URLFAIL;
|
return DLG_URLFAIL;
|
||||||
}
|
}
|
||||||
totalSize += strlen(tempBuf) + 1; // +1 for null terminator
|
totalSize += strlen(tempBuf) + 1; // +1 for null terminator
|
||||||
}
|
}
|
||||||
totalSize += 1; // Final null terminator
|
totalSize += 1; // Final null terminator
|
||||||
|
|
||||||
if(totalSize > self->params->nbuf) {
|
if(totalSize > self->params->nbuf) {
|
||||||
// Not enough buffer space
|
// Not enough buffer space
|
||||||
return DLG_URLFAIL;
|
return DLG_URLFAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now actually copy the paths (we know we have space)
|
// Now actually copy the paths (we know we have space)
|
||||||
bufPtr = self->params->buf;
|
bufPtr = self->params->buf;
|
||||||
for(NSURL* url in urls) {
|
for(NSURL* url in urls) {
|
||||||
char tempBuf[PATH_MAX];
|
char tempBuf[PATH_MAX];
|
||||||
[url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX];
|
[url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX];
|
||||||
int pathLen = strlen(tempBuf);
|
int pathLen = strlen(tempBuf);
|
||||||
strcpy(bufPtr, tempBuf);
|
strcpy(bufPtr, tempBuf);
|
||||||
bufPtr += pathLen + 1;
|
bufPtr += pathLen + 1;
|
||||||
}
|
}
|
||||||
*bufPtr = '\0'; // Final null terminator
|
*bufPtr = '\0'; // Final null terminator
|
||||||
|
} else {
|
||||||
|
// Single file/directory selection - write path to buffer
|
||||||
|
NSURL* url = [urls firstObject];
|
||||||
|
if(![url getFileSystemRepresentation:self->params->buf maxLength:self->params->nbuf]) {
|
||||||
|
return DLG_URLFAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DLG_OK;
|
return DLG_OK;
|
||||||
|
|||||||
@@ -224,9 +224,7 @@ func (s *Server) cmd(ctx context.Context) (*exec.Cmd, error) {
|
|||||||
if _, err := os.Stat(settings.Models); err == nil {
|
if _, err := os.Stat(settings.Models); err == nil {
|
||||||
env["OLLAMA_MODELS"] = settings.Models
|
env["OLLAMA_MODELS"] = settings.Models
|
||||||
} else {
|
} else {
|
||||||
slog.Warn("models path not accessible, clearing models setting", "path", settings.Models, "err", err)
|
slog.Warn("models path not accessible, using default", "path", settings.Models, "err", err)
|
||||||
settings.Models = ""
|
|
||||||
s.store.SetSettings(settings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if settings.ContextLength > 0 {
|
if settings.ContextLength > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user