Commit graph

2997 commits

Author SHA1 Message Date
Joey Hess
c74c75b352
more OsPath conversion (639/749)
Sponsored-by: k0ld
2025-02-07 16:07:05 -04:00
Joey Hess
a5d48edd94
more OsPath conversion (602/749)
Sponsored-by: Brock Spratlen
2025-02-07 14:46:11 -04:00
Joey Hess
2d1db7986c
more OsPath conversion (572/749)
Sponsored-by: Jack Hill
2025-02-06 16:18:52 -04:00
Joey Hess
0811531b59
more OsPath conversion (542/749)
Sponsored-by: Luke T. Shumaker
2025-02-06 11:38:14 -04:00
Joey Hess
77e9781ae2
parsePOSIXTime ByteString conversion
Some easy (though tiny) speed wins.

Sponsored-by: Luke T. Shumaker on Patreon
2025-01-22 16:42:09 -04:00
Joey Hess
6e27b0d4d1
convert from readFileStrict
This removes that function, using file-io readFile' instead.

Had to deal with newline conversion, which readFileStrict does on
Windows. In a few cases, that was pretty ugly to deal with.

Sponsored-by: Kevin Mueller
2025-01-22 16:20:36 -04:00
Joey Hess
9b79f0f43d
use file-io for readFile/writeFile/appendFile on ByteStrings
These are all straightforward, and easy small performance wins.

Sponsored-by: Nicholas Golder-Manning
2025-01-22 14:30:25 -04:00
Joey Hess
90cd3aad37
RawFilePath conversion for replaceFile
Sponsored-by: Joshua Antonishen
2025-01-22 13:37:26 -04:00
Joey Hess
f17ec601c4
optimize truncateFilePath
Often the filepath will be all ascii, or mostly so, and this
optimisation makes a file that has an ascii suffix of sufficient length
be roundtrip converted between String and ByteString only once, rather
than once per character.

Sponsored-by: Graham Spencer
2025-01-22 13:09:15 -04:00
Joey Hess
793ddecd4b
use openTempFile from file-io
And follow-on changes.

Note that relatedTemplate was changed to operate on a RawFilePath, and
so when it counts the length, it is now the number of bytes, not the
number of code points. This will just make it truncate shorter strings
in some cases, the truncation is still unicode aware.

When not building with the OsPath flag, toOsPath . fromRawFilePath and
fromRawFilePath . fromOsPath do extra conversions back and forth between
String and ByteString. That overhead could be avoided, but that's the
non-optimised build mode, so didn't bother.

Sponsored-by: unqueued
2025-01-22 11:41:43 -04:00
Joey Hess
1faa3af9cd
add file-io to build-depends when building with OsPath flag
Partly converted code to use functions from it, though more remain
unconverted. Most of withFile and openFile now use it.
2025-01-21 14:26:04 -04:00
Joey Hess
1ceece3108
RawFilePath conversion of System.Directory
By using System.Directory.OsPath, which takes and returns OsString,
which is a ShortByteString. So, things like dirContents currently have the
overhead of copying that to a ByteString, but that should be less than
the overhead of using Strings which often in turn were converted to
RawFilePaths.

Added Utility.OsString and the OsString build flag. That flag is turned
on in the stack.yaml, and will be turned on automatically by cabal when
built with new enough libraries. The stack.yaml change is a bit ugly,
and that could be reverted for now if it causes any problems.

Note that Utility.OsString.toOsString on windows is avoiding only a
check of encoding that is documented as being unlikely to fail. I don't
think it can fail in git-annex; if it could, git-annex didn't contain
such an encoding check before, so at worst that should be a wash.
2025-01-20 19:17:33 -04:00
Joey Hess
9e4314de76
relax annex-tracking-branch to allow "/"
Allow setting remote.foo.annex-tracking-branch to a branch name that
contains "/", as long as it's not a remote tracking branch.
2025-01-20 11:31:18 -04:00
Joey Hess
5df1b2b36e
configs annex.post-update-command and annex.pre-commit-command
Added git configs annex.post-update-command and annex.pre-commit-command
that correspond to the git-annex hook scripts post-update-annex and
pre-commit-annex.

Note that the hook files take precience over the git config, since the git
config can includ global config which should be overridden by local config.

These new git configs are probably not super useful. Especially the
pre-commit-annex hook is there to install scripts to instead of the
pre-commit hook, since git-annex installs that hook itself. So why would
someone want to use a git config for that? Only reason I can think of would
be in a global git config. Or possibly because it's easier to set a git
config than write a hook script, on an OS like Windows.

The real reason I'm adding these is as groundwork for making other
annex.*-command git configs also be available as hook scripts. I want
to avoid having some things available as only git hooks and others as
both gitconfigs and git hooks. (It seems that some annex.*-command configs
don't translate to git hooks though.)

In the man page, moved documentation of the hooks to be next to the
documentation of the git configs. This is to avoid repitition.
2025-01-10 13:27:51 -04:00
Joey Hess
0815c82bb1
log: Support --key, as well as --branch and --unused
--all remains a special case, since it is more efficient and displays in a
nicer order.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-01-03 15:45:42 -04:00
Joey Hess
da5e195597
remove i386ancient and need at least debian stable to build
* Removed the i386ancient standalone tarball build for linux, which
  was increasingly unable to support new git-annex features.
* Removed support for building with ghc older than 9.0.2,
  and with older versions of haskell libraries than are in current Debian
  stable.
* stack.yaml: Update to lts-23.2.

Note that i386ancient was targeting linux 2.6.32, which has been EOL for
over 9 years now. Any old system still using such a kernel is certainly highly
insecure. And I suspect i386ancient had its own insecurities due to haskell
libraries and C libraries not having been updated.
2025-01-01 14:15:55 -04:00
Joey Hess
29b3c7c660
annex.addunlocked support for tree imports
Honor annex.addunlocked configuration when importing a tree from a special
remote.

Note, in a --no-content import, the object file will not be populated
(usually) and so expressions that match on mime type will not match. Tested
this and it works ok, the file just ends up locked. Updated docs for the
mime expressions to mention that they can't match when the file is present

Note that in Command.Sync.pullThirdPartyPopulated, recordImportTree is
called without a AddUnlockedMatcher. Since the tree generated here is not
exposed to the user and does not contain usual filenames, there is no need
of the overhead of checking it.
2024-12-19 11:43:51 -04:00
Joey Hess
7d8558548b
empty preferred content
* Document that settting preferred content to "" is the same as the
  default unset behavior.
* sync: Avoid misleading warning about future preferred content
  transition when preferred content is set to "".
2024-12-13 13:26:48 -04:00
Joey Hess
4c785c338a
p2phttp: notice when new repositories are added to --directory
When a uuid is not known, rescan for new repositories. Easy.

When a repository is removed, it will also get removed from the server
state on the next scan. But until a new uuid is seen, there will not be
a scan. This leaves the server trying to serve a uuid whose repository
is gone. That seems buggy. While getting just fails, dropping fails the
first time, but seems to leave the server in an unusable state, so the
next drop attempt hangs. The server is still able to serve other uuids,
only the one whose repository was removed has that problem.
2024-11-21 15:09:12 -04:00
Joey Hess
758ea89c74
skip over repositories in --directory that do not have annex.uuid set 2024-11-21 14:18:18 -04:00
Joey Hess
3c18398d5a
p2phttp support --jobs with --directory
--jobs is usually an Annex option setter, but --directory runs in IO, so
would not have that available. So instead moved the option parser into
the command's Options.
2024-11-21 14:15:14 -04:00
Joey Hess
9f84dd82da
p2phttp --directory implementation
Untested, but it compiles, so.

Known problems:

* --jobs is not available to startIO
* Does not notice when new repositories are added to a directory.
* Does not notice when repositories are removed from a directory.
2024-11-21 14:02:58 -04:00
Joey Hess
6bdf4a85fb
move the p2phttp server state map into a data type 2024-11-21 12:24:14 -04:00
Joey Hess
07026cf58b
add proxied uuids to http server state map
This fixes support for proxying after last commit broke it.

Note that withP2PConnections is called at server startup, and so only
proxies seen at that point will appear in the map and be used. It was
already the case that a proxy added after p2phttp was running would not
be served.

I think that is possibly a bug, but at least this commit doesn't
introduce the problem, though it might make it harder to fix it.

As bugs go, it's probably not a big deal, because after all,
git configs needs to be set in the local repository, followed by
git-annex updateproxy being run, to set up proxying. If someone is doing
that, they can restart their http server I suppose.
2024-11-20 13:22:25 -04:00
Joey Hess
254073569f
p2pHttpApp with a map of UUIDs to server states
This is early groundwork for making p2phttp support serving multiple
repositories from a single daemon.

So far only 1 repository is served still. And this commit breaks support
for proxying!
2024-11-20 12:51:25 -04:00
Joey Hess
b94221594b
add: When adding a dotfile as a non-large file, mention that it's a dotfile
This is to reduce user confusion when their annex.largefiles matches it,
or is not set.

Note that, when annex.dotfiles is set, but a dotfile is not matched by
annex.largefiles, the "non-large file" message will be displayed. That
makes sense because whether the file is a dotfile does not matter with that
configuration.

Also, this slightly optimised the annex.dotfiles path in passing,
by avoiding the slight slowdown caused by the check added in commit
876d5b6c6f in that case.
2024-11-13 14:09:24 -04:00
Joey Hess
876d5b6c6f
add: Consistently treat files in a dotdir as dotfiles, even when ran inside that dotdir
Assistant and smudge also updated.

This does add a small amount of extra work, getting the TopFilePath.
Not enough to be concerned by.

Also improve documentation to make clear that files inside dotdirs are
treated as dotfiles.

Sponsored-by: Eve on Patreon
2024-11-13 13:43:01 -04:00
Joey Hess
447e6adabd
vpop: Only update state after successful checkout
If checkout fails for some reason, they're still in a view, and should be
able to vpop again.
2024-11-11 14:15:51 -04:00
Joey Hess
bdf3a4747f
adjust: Allow any order of options when combining --hide-missing with options like --unlock.
optparse-applicative made this hard, the naive implementation this had
before didn't let --hide-missing come after --unlock. And just adding
additional <|> with --hide-missing coming after --unlock didn't work
either. So need to get some options and then combine them.
2024-10-21 16:03:39 -04:00
Joey Hess
2c14181bcb
better name for LinkPresentAdjustment 2024-10-21 15:42:01 -04:00
Joey Hess
de138c642b
p2phttp: Allow unauthenticated users to lock content by default
* p2phttp: Allow unauthenticated users to lock content by default.
* p2phttp: Added --unauth-nolocking option to prevent unauthenticated
  users from locking content.

The rationalle for this is that locking is not really a write operation, so
makes sense to allow in a repository that only allows read-only access. Not
supporting locking in that situation will prevent the user from dropping
content from a special remote they control in cases where the other copy of
the content is on the p2phttp server.

Also, when p2phttp is configured to also allow authenticated access,
lockcontent was resulting in a password prompt for users who had no way to
authenticate. And there is no good way to distinguish between the two types
of users client side.

--unauth-nolocking anticipates that this might be abused, and seems better
than disabling unauthenticated access entirely if a server is being
attacked. It may be that rate limiting locking by IP address or similar
would be an effective measure in such a situation. Or just limiting the
number of locks by anonymous users that can be live at any one time. Since
the impact of such an DOS attempt is limited to preventing dropping content
from the server, it seems not a very appealing target anyway.
2024-10-21 10:02:12 -04:00
Joey Hess
0629219617
p2phttp combining unauth and auth options
p2phttp: Support serving unauthenticated users while requesting
authentication for operations that need it. Eg, --unauth-readonly can be
combined with --authenv.

Drop locking currently needs authentication so it will prompt for that.
That still needs to be addressed somehow.
2024-10-17 11:10:28 -04:00
Joey Hess
743690d022
fix build with old random
getStdGen used to be an IO not a MonadIO action
2024-09-30 17:36:19 -04:00
Joey Hess
d2ad07f5a3
fix build with random-1.2
getStdGen worked with that version but initStdGen is newer. For our
purposes, they are equivilant.
2024-09-30 14:56:06 -04:00
Joey Hess
936f22273e
avoid head
While in some sense this is better, the use of NE.fromList is still
partial.
2024-09-26 17:53:00 -04:00
Joey Hess
30713ab0d3
avoid head
Seems like generate works fine to generate a single arbitrary value, I
dunno why I used sample' originally.
2024-09-26 17:49:41 -04:00
Joey Hess
5a8add5d55
remove slightly unsafe use of head
If git rev-parse somehow didn't output anything, git-annex would crash
here.
2024-09-26 17:21:22 -04:00
Joey Hess
76362278e9
export only the parts of aeson that are used
Rather than hiding things not wanted. This fixes a build warning with
aeson-2.2.3 which no longer has a json function.
2024-09-25 14:41:23 -04:00
Joey Hess
8047128591
sim: quiesce before freezing or ending
Probably a good idea for freezing, but especially I hope this fixes a
problem with git-annex sim run that caused it to sometimes crash in
removeDirectoryRecursive with directory not empty, presumably because a
thread was writing there at the same time.
2024-09-24 16:46:09 -04:00
Joey Hess
540bd5e1ab
sim: added run subcommand
And a nice sim of random preferred content expressions.
2024-09-24 12:06:34 -04:00
Joey Hess
9571162057
sim: add stepstable 2024-09-24 11:50:24 -04:00
Joey Hess
7bc8c2bfeb
sim visit as first-class command
Allows using it in a sim file.
2024-09-23 13:09:35 -04:00
Joey Hess
e9c59eceb8
bugfixes
sim stabilization works now
2024-09-20 15:39:52 -04:00
Joey Hess
bab330de33
remove sim log file 2024-09-20 15:03:54 -04:00
Joey Hess
e568ac96b7
record initial seed in sim log
Unless the log starts with a command that records a seed.
2024-09-17 13:49:50 -04:00
Joey Hess
02f0996e25
git-annex sim log 2024-09-17 13:43:11 -04:00
Joey Hess
2cbd3fb26b
sim command fixes 2024-09-12 16:39:44 -04:00
Joey Hess
52891711d2
git-annex sim command is working
Had to add Read instances to Key and NumCopies and some other similar
types. I only expect to use those in serializing a sim. Of course, this
risks that implementation changes break reading old data. For a sim,
that would not be a big problem.
2024-09-12 16:10:52 -04:00
Joey Hess
7b931df475
fully preserve input format of connect and disconnect commands
Just lifted the sim file as a DSL into the type level for that.
2024-09-11 21:01:13 -04:00
Joey Hess
f381b457f2
sim file parser and generator
The generator doesn't emit the best possible connect commands,
but it does output something valid. Eg, an input like:

connect A <-> B <-> C <-> D

becomes:

connect A <-> B <-> C
connect C <-> D

Also:

connect A -> B <- C

becomes:

connect A -> B
connect C -> B

Which could be improved.

Also disconnect commands are not prettified at all, but probably there's
no reason to.
2024-09-11 15:59:13 -04:00